Skip analyzer strndup test on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / gcc.dg / addr_equal-1.c
blobdb65dea4a8d2a683ff163d00186e68d435165fca
1 /* { dg-do run { target { { nonpic || pie_enabled } && weak_undefined } } } */
2 /* { dg-require-alias "" } */
3 /* { dg-options "-O2 -fdelete-null-pointer-checks" } */
4 /* { dg-skip-if "function pointers can be NULL" { keeps_null_pointer_checks } } */
5 /* { dg-add-options weak_undefined } */
6 void abort (void);
7 extern int undef_var0, undef_var1;
8 extern __attribute__ ((weak)) int weak_undef_var0;
9 extern __attribute__ ((weak)) int weak_undef_var1;
10 __attribute__ ((weak)) int weak_def_var0;
11 int def_var0=0, def_var1=0;
12 static int alias_var0 __attribute__ ((alias("def_var0")));
13 extern int weak_alias_var0 __attribute__ ((alias("def_var0"))) __attribute__ ((weak));
14 void undef_fn0(void);
15 void undef_fn1(void);
16 void def_fn0(void)
19 void def_fn1(void)
22 __attribute__ ((weak))
23 void weak_def_fn0(void)
26 __attribute__ ((weak))
27 void weak_def_fn1(void)
30 __attribute__ ((weak)) void weak_undef_fn0(void);
32 inline
33 void inline_fn0(void)
36 inline
37 void inline_fn1(void)
41 int
42 main(int argc, char **argv)
44 /* Two definitions are always different unless they can be interposed. */
45 if (!__builtin_constant_p (def_fn0 == def_fn1))
46 abort();
47 if (def_fn0 == def_fn1)
48 abort();
50 if (!__builtin_constant_p (&def_var0 == &def_var1))
51 abort();
52 if (&def_var0 == &def_var1)
53 abort();
55 /* Same symbol is the same no matter on interposition. */
56 if (!__builtin_constant_p (undef_fn0 != undef_fn0))
57 abort ();
58 if (undef_fn0 != undef_fn0)
59 abort ();
61 /* Do not get confused by same offset. */
62 if (!__builtin_constant_p (&undef_var0 + argc != &undef_var0 + argc))
63 abort ();
64 if (&undef_var0 + argc != &undef_var0 + argc)
65 abort ();
67 /* Alias and its target is equivalent unless one of them can be interposed. */
68 if (!__builtin_constant_p (&def_var0 != &alias_var0))
69 abort ();
70 if (&def_var0 != &alias_var0 )
71 abort ();
73 if (__builtin_constant_p (&def_var0 != &weak_alias_var0))
74 abort ();
75 if (&def_var0 != &weak_alias_var0)
76 abort ();
78 /* Weak definitions may be both NULL. */
79 if (__builtin_constant_p ((void *)weak_undef_fn0 == (void *)&weak_undef_var0))
80 abort ();
81 if ((void *)weak_undef_fn0 != (void *)&weak_undef_var0)
82 abort ();
84 /* Variables and functions do not share same memory locations otherwise. */
85 if (!__builtin_constant_p ((void *)undef_fn0 == (void *)&undef_var0))
86 abort ();
87 if ((void *)undef_fn0 == (void *)&undef_var0)
88 abort ();
90 /* This works for cases where one object is just weakly defined, too. */
91 if (!__builtin_constant_p ((void *)weak_undef_fn0 == (void *)&weak_def_var0))
92 abort ();
93 if ((void *)weak_undef_fn0 == (void *)&weak_def_var0)
94 abort ();
96 /* Inline functions are known to be different. */
97 if (!__builtin_constant_p (inline_fn0 != inline_fn1))
98 abort ();
99 if (inline_fn0 == inline_fn1)
100 abort ();
101 return 0;