2 /* { dg-require-effective-target nonpic } */
3 /* { dg-require-weak "" } */
4 /* { dg-require-alias "" } */
5 /* { dg-options "-O2" } */
6 /* { dg-skip-if "" { powerpc-ibm-aix* } } */
8 extern int undef_var0
, undef_var1
;
9 extern __attribute__ ((weak
)) int weak_undef_var0
;
10 extern __attribute__ ((weak
)) int weak_undef_var1
;
11 __attribute__ ((weak
)) int weak_def_var0
;
12 int def_var0
=0, def_var1
=0;
13 static int alias_var0
__attribute__ ((alias("def_var0")));
14 extern int weak_alias_var0
__attribute__ ((alias("def_var0"))) __attribute__ ((weak
));
23 __attribute__ ((weak
))
24 void weak_def_fn0(void)
27 __attribute__ ((weak
))
28 void weak_def_fn1(void)
31 __attribute__ ((weak
)) void weak_undef_fn0(void);
43 main(int argc
, char **argv
)
45 /* Two definitions are always different unless they can be interposed. */
46 if (!__builtin_constant_p (def_fn0
== def_fn1
))
48 if (def_fn0
== def_fn1
)
51 if (!__builtin_constant_p (&def_var0
== &def_var1
))
53 if (&def_var0
== &def_var1
)
56 /* Same symbol is the same no matter on interposition. */
57 if (!__builtin_constant_p (undef_fn0
!= undef_fn0
))
59 if (undef_fn0
!= undef_fn0
)
62 /* Do not get confused by same offset. */
63 if (!__builtin_constant_p (&undef_var0
+ argc
!= &undef_var0
+ argc
))
65 if (&undef_var0
+ argc
!= &undef_var0
+ argc
)
68 /* Alias and its target is equivalent unless one of them can be interposed. */
69 if (!__builtin_constant_p (&def_var0
!= &alias_var0
))
71 if (&def_var0
!= &alias_var0
)
74 if (__builtin_constant_p (&def_var0
!= &weak_alias_var0
))
76 if (&def_var0
!= &weak_alias_var0
)
79 /* Weak definitions may be both NULL. */
80 if (__builtin_constant_p ((void *)weak_undef_fn0
== (void *)&weak_undef_var0
))
82 if ((void *)weak_undef_fn0
!= (void *)&weak_undef_var0
)
85 /* Variables and functions do not share same memory locations otherwise. */
86 if (!__builtin_constant_p ((void *)undef_fn0
== (void *)&undef_var0
))
88 if ((void *)undef_fn0
== (void *)&undef_var0
)
91 /* This works for cases where one object is just weakly defined, too. */
92 if (!__builtin_constant_p ((void *)weak_undef_fn0
== (void *)&weak_def_var0
))
94 if ((void *)weak_undef_fn0
== (void *)&weak_def_var0
)
97 /* Inline functions are known to be different. */
98 if (!__builtin_constant_p (inline_fn0
!= inline_fn1
))
100 if (inline_fn0
== inline_fn1
)