Rebase.
[official-gcc.git] / gcc / testsuite / gcc.dg / localalias.c
blob6384875b3e53f50998e257b81418d37ad929a762
1 /* This test checks that local aliases behave sanely. This is necessary for code correctness
2 of aliases introduced by ipa-visibility pass.
4 If this test fails either aliases needs to be disabled on given target on aliases with
5 proper semantic needs to be implemented. This is problem with e.g. AIX .set pseudo-op
6 that implementes alias syntactically (by substituting in assembler) rather as alternative
7 symbol defined on a target's location. */
9 /* { dg-do run }
10 { dg-options "-Wstrict-aliasing=2 -fstrict-aliasing" }
11 { dg-require-alias "" }
12 { dg-additional-sources "localalias-2.c" } */
13 extern void abort (void);
14 extern int test2count;
15 int testcount;
16 __attribute__ ((weak,noinline))
17 void test(void)
19 testcount++;
21 __attribute ((alias("test")))
22 static void test2(void);
24 int main()
26 test2();
27 /* This call must bind locally. */
28 if (!testcount)
29 abort ();
30 test();
31 /* Depending on linker choice, this one may bind locally
32 or to the other unit. */
33 if (!testcount && !test2count)
34 abort();
35 tt();
37 if ((testcount != 1 || test2count != 3)
38 && (testcount != 3 || test2count != 1))
39 abort ();
40 return 0;