OSDN Git Service

Update gcc.dg/atomic-flag.c test for non-boolean TAS targets.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / constructor-1.c
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3
4 /* The ipa-split pass pulls the body of the if(!x) block
5    into a separate function to make foo a better inlining
6    candidate.  Make sure this new function isn't also run
7    as a static constructor.  */
8
9 #include <stdlib.h>
10
11 int x, y;
12
13 void __attribute__((noinline))
14 bar(void)
15 {
16   y++;
17 }
18
19 void __attribute__((constructor))
20 foo(void)
21 {
22   if (!x)
23     {
24       bar();
25       y++;
26     }   
27
28
29 int main()
30 {
31   x = 1;
32   foo();
33   foo();
34   if (y != 2)
35     abort();
36   exit(0);
37 }