2009-07-17 Richard Guenther <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pta-ptrarith-3.c
blob6c08319d8c53fb11b6c13cca092823ee8ec5296b
1 /* { dg-do run } */
2 /* { dg-options "-fdump-tree-alias" } */
3 /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
5 extern void abort (void);
6 struct X {
7 int *p;
8 int *q;
9 int *r;
11 int __attribute__((noinline))
12 foo(int i, int j, int k, int off)
14 struct X x;
15 int **p, *q;
16 x.p = &i;
17 x.q = &j;
18 x.r = &k;
19 p = &x.q;
20 p += off;
21 /* *p points to { i, j, k } */
22 q = *p;
23 return *q;
25 int main()
27 if (foo(1, 2, 3, -1) != 1)
28 abort ();
29 if (foo(1, 2, 3, 0) != 2)
30 abort ();
31 if (foo(1, 2, 3, 1) != 3)
32 abort ();
33 return 0;
36 /* { dg-final { scan-tree-dump "q_., points-to vars: { i j k }" "alias" } } */
37 /* { dg-final { cleanup-tree-dump "alias" } } */