struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr39100.c
blob8487f024279273be7196414594d1fe6e78d106ac
1 /*
2 pr39100.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 /* Bad PTA results (incorrect store handling) was causing us to delete
13 *na = 0 store. */
15 typedef struct E
17 int p;
18 struct E *n;
19 } *EP;
21 typedef struct C
23 EP x;
24 short cn, cp;
25 } *CP;
27 #ifndef __SDCC_pdk14 // Lack of memory
29 foo (CP h, EP x)
31 EP pl = 0, *pa = &pl;
32 EP nl = 0, *na = &nl;
33 EP n;
35 while (x)
37 n = x->n;
38 if ((x->p & 1) == 1)
40 h->cp++;
41 *pa = x;
42 pa = &((*pa)->n);
44 else
46 h->cn++;
47 *na = x;
48 na = &((*na)->n);
50 x = n;
52 *pa = nl;
53 *na = 0;
54 h->x = pl;
55 return h;
57 #endif
59 void
60 testTortureExecute (void)
62 #ifndef __SDCC_pdk14 // Lack of memory
63 struct C c = { 0, 0, 0 };
64 struct E e[2] = { { 0, &e[1] }, { 1, 0 } };
65 EP p;
67 foo (&c, &e[0]);
68 if (c.cn != 1 || c.cp != 1)
69 ASSERT (0);
70 if (c.x != &e[1])
71 ASSERT (0);
72 if (e[1].n != &e[0])
73 ASSERT (0);
74 if (e[0].n)
75 ASSERT (0);
76 return;
77 #endif