struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20000603-1.c
blob023a1b816a11564114f908fb49b315b09549ce91
1 /*
2 20000603-1.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 93
10 #endif
12 /* It is not clear whether this test is conforming. See DR#236
13 http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_236.htm. However,
14 there seems to be consensus that the presence of a union to aggregate
15 struct s1 and struct s2 should make it conforming. */
16 struct s1 { double d; };
17 struct s2 { double d; };
18 union u { struct s1 x; struct s2 y; };
20 #ifndef __SDCC_pdk14 // Lack of memory
21 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
22 double f(struct s1 *a, struct s2 *b)
24 a->d = 1.0;
25 return b->d + 1.0;
27 #endif
28 #endif
30 void
31 testTortureExecute (void)
33 #ifndef __SDCC_pdk14 // Lack of memory
34 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
35 union u a;
36 a.x.d = 0.0;
37 if (f (&a.x, &a.y) != 2.0)
38 ASSERT (0);
39 return;
40 #endif
41 #endif