2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / gcc / testsuite / gcc.dg / globalalias.c
blob2c6ae51b4b2f4a4eecd5f8d5cd79d6d70970c73e
1 /* This test checks that local aliases behave sanely. This is necessary for code correctness
2 of aliases introduced by ipa-visibility pass.
4 This test expose weird behaviour of AIX's .set pseudo-op where the global symbol is created,
5 but all uses of the alias are syntactically replaced by uses of the target. This means that
6 both counters are increased to 2. */
8 /* { dg-do run }
9 { dg-options "-O2" }
10 { dg-require-alias "" }
11 { dg-additional-sources "globalalias-2.c" } */
12 extern int test2count;
13 extern void abort (void);
14 int testcount;
15 static
16 void test(void)
18 testcount++;
20 __attribute__ ((weak,noinline))
21 __attribute ((alias("test")))
22 void test2(void);
24 int main()
26 test();
27 /* This call must bind locally. */
28 if (!testcount)
29 abort ();
30 test2();
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;