Fix broken MinGW build of gcc.c
[official-gcc.git] / gcc / testsuite / gcc.dg / pr33136-2.c
blob760b5a06fdd518f2a450c1f2323c09a1b0ad4ff5
1 /* PR tree-optimization/33136 */
2 /* { dg-do run } */
3 /* { dg-options "-O2" } */
5 extern void abort (void);
7 struct S
9 void *a;
10 int b;
11 int *c;
13 static int d, e;
15 static struct S s;
17 static int *
18 __attribute__((noinline, const))
19 foo (void)
21 return &s.b;
24 int *
25 __attribute__((noinline))
26 bar (int **f)
28 s.c = &d;
29 *f = &e;
30 /* As nothing ever takes the address of any int * field in struct S,
31 the write to *f can't alias with the s.c field. */
32 return s.c;
35 int
36 __attribute__((noinline))
37 baz (int *x)
39 s.b = 1;
40 *x = 4;
41 /* Function foo takes address of an int field in struct S,
42 so *x can alias with the s.b field (and it does in this testcase). */
43 return s.b;
46 int
47 __attribute__((noinline))
48 t (void)
50 int *f = (int *) 0;
51 return 10 * (bar (&f) != &d) + baz (foo ());
54 int
55 main (void)
57 if (t () != 4)
58 abort ();
59 return 0;