OSDN Git Service

Backported from mainline
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.c-torture / execute / pr51466.c
1 /* PR tree-optimization/51466 */
2
3 extern void abort (void);
4
5 __attribute__((noinline, noclone)) int
6 foo (int i)
7 {
8   volatile int v[4];
9   int *p;
10   v[i] = 6;
11   p = (int *) &v[i];
12   return *p;
13 }
14
15 __attribute__((noinline, noclone)) int
16 bar (int i)
17 {
18   volatile int v[4];
19   int *p;
20   v[i] = 6;
21   p = (int *) &v[i];
22   *p = 8;
23   return v[i];
24 }
25
26 __attribute__((noinline, noclone)) int
27 baz (int i)
28 {
29   volatile int v[4];
30   int *p;
31   v[i] = 6;
32   p = (int *) &v[0];
33   *p = 8;
34   return v[i];
35 }
36
37 int
38 main ()
39 {
40   if (foo (3) != 6 || bar (2) != 8 || baz (0) != 8 || baz (1) != 6)
41     abort ();
42   return 0;
43 }