struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr51466.c
blobb7a51666e5c35623ebcb6bcde678e63171be28d2
1 /*
2 pr51466.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 /* PR tree-optimization/51466 */
13 int
14 foo (int i)
16 volatile int v[4];
17 int *p;
18 v[i] = 6;
19 p = (int *) &v[i];
20 return *p;
23 int
24 bar (int i)
26 volatile int v[4];
27 int *p;
28 v[i] = 6;
29 p = (int *) &v[i];
30 *p = 8;
31 return v[i];
34 int
35 baz (int i)
37 volatile int v[4];
38 int *p;
39 v[i] = 6;
40 p = (int *) &v[0];
41 *p = 8;
42 return v[i];
45 void
46 testTortureExecute (void)
48 if (foo (3) != 6 || bar (2) != 8 || baz (0) != 8 || baz (1) != 6)
49 ASSERT (0);
50 return;