OSDN Git Service

2010-03-31 Martin Jambor <mjambor@suse.cz>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / torture / pta-ptrarith-2.c
1 /* { dg-do run } */
2 /* { dg-options "-fdump-tree-alias" } */
3 /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
4
5 struct Foo {
6   int **p;
7   int **q;
8 };
9
10 int __attribute__((noinline))
11 bar (void)
12 {
13   struct Foo f;
14   int j, i = 1;
15   char *p;
16   int *x = &i;
17   int *y = &j;
18   f.p = &y;
19   f.q = &x;
20   p = (char *)&f;
21   for (j = 0; j < sizeof (int *); ++j)
22     p++;
23   return ***(int ***)p;
24 }
25 extern void abort (void);
26 int main()
27 {
28   if (bar () != 1)
29     abort ();
30   return 0;
31 }
32
33 /* In theory = { i } is the correct solution.  But it's not easy to scan
34    for that reliably, so just use what we create now.  */
35 /* { dg-final { scan-tree-dump "= { i j }" "alias" } } */
36 /* { dg-final { cleanup-tree-dump "alias" } } */