OSDN Git Service

Add NIOS2 support. Code from SourceyG++.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / torture / pta-ptrarith-3.c
1 /* { dg-do run } */
2 /* { dg-options "-fdump-tree-alias" } */
3 /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
4
5 extern void abort (void);
6 struct X {
7   int *p;
8   int *q;
9   int *r;
10 };
11 int __attribute__((noinline))
12 foo(int i, int j, int k, int off)
13 {
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;
24 }
25 int main()
26 {
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;
34 }
35
36 /* { dg-final { scan-tree-dump "q_., points-to vars: { i j k }" "alias" } } */
37 /* { dg-final { cleanup-tree-dump "alias" } } */