struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr49419.c
blobcec9f0a2b1cf2bc01097b86ef9afbd522e139915
1 /*
2 pr49419.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #pragma disable_warning 85
10 #endif
12 /* PR tree-optimization/49419 */
14 struct S { int w, x, y; } *t;
16 #ifndef __SDCC_pdk14 // Lack of memory
17 int
18 foo (int n, int f, int *s, int m)
20 int x, i, a;
21 if (n == -1)
22 return 0;
23 for (x = n, i = 0; t[x].w == f && i < m; i++)
24 x = t[x].x;
25 if (i == m)
26 ASSERT (0);
27 a = i + 1;
28 for (x = n; i > 0; i--)
30 s[i] = t[x].y;
31 x = t[x].x;
33 s[0] = x;
34 return a;
36 #endif
38 void
39 testTortureExecute (void)
41 #ifndef __SDCC_pdk14 // Lack of memory
42 int s[3], i;
43 struct S buf[3] = { { 1, 1, 2 }, { 0, 0, 0 }, { 0, 0, 0 } };
44 t = buf;
45 if (foo (0, 1, s, 3) != 2)
46 ASSERT (0);
47 if (s[0] != 1 || s[1] != 2)
48 ASSERT (0);
49 return;
50 #endif