struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2357.c
blob1f952688f7014761030237b59f8b44fb88c7df18
1 /*
2 bug-2357.c
3 */
5 #include <testfwk.h>
6 #include <string.h>
8 #ifdef __SDCC
9 #pragma std_c99
10 #endif
12 #if defined (__SDCC) && !defined (__SDCC_pdk14) && !defined (__SDCC_pdk15) && !defined (__SDCC_pic14) && (!defined (__SDCC_mcs51) || (!defined (__SDCC_MODEL_SMALL) && !defined (__SDCC_MODEL_MEDIUM) && !defined (__SDCC_STACK_AUTO)))
14 short i = -1;
15 union {
16 short sv0[126];
17 short sv1[132];
18 long lv0[63];
19 long lv1[66];
20 } uv;
22 short
23 foo2(void)
25 return uv.sv1[132 + i];
28 long
29 foo3(void)
31 return uv.lv1[66 + i];
34 short
35 foo4(void)
37 return uv.sv0[126 + i];
40 long
41 foo5(void)
43 return uv.lv0[63 + i];
46 #endif
48 void
49 testBug (void)
51 #if defined (__SDCC) && !defined (__SDCC_pdk14) && !defined (__SDCC_pdk15) && !defined (__SDCC_pic14) && (!defined (__SDCC_mcs51) || (!defined (__SDCC_MODEL_SMALL) && !defined (__SDCC_MODEL_MEDIUM) && !defined (__SDCC_STACK_AUTO)))
53 memset(&uv, 0x33, 128);
54 memset((char *) &uv + 128, 0x55, 136);
56 ASSERT (foo2() == 0x5555);
57 ASSERT (foo3() == 0x55555555L);
59 ASSERT (foo4() == 0x5555);
60 ASSERT (foo5() == 0x55555555L);
62 #endif