struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2031.c
blobcfac19c539b412b1298a84a9533603cbfba9ca2b
1 /*
2 bug-2031.c
3 */
5 #include <testfwk.h>
7 struct bugtest {
8 unsigned int i;
9 unsigned char c;
10 unsigned long l;
13 unsigned long gv;
14 unsigned long *gp = &gv;
15 #ifdef __SDCC
16 unsigned int gi = (unsigned int) &gv;
17 unsigned long gl = (unsigned long) &gv;
18 unsigned char gc = (unsigned char) &gv;
20 struct bugtest gs = {
21 (unsigned int) &gv,
22 (unsigned char) &gv,
23 (unsigned long) &gv,
25 #endif // __SDCC
27 void testBug(void)
29 #ifdef __SDCC
30 unsigned long lv;
31 unsigned long *lp = &lv;
32 unsigned char lc = (unsigned char) &lv;
33 unsigned int li = (unsigned int) &lv;
34 unsigned long ll = (unsigned long) &lv;
35 #ifndef __SDCC_pdk14 // Not enough RAM
36 struct bugtest ls = {(unsigned int) &lv, (unsigned char) &lv, (unsigned long) &lv};
37 #endif
39 ASSERT (gc == (unsigned char) gp);
40 ASSERT (gi == (unsigned int) gp);
41 ASSERT (gl == (unsigned long) gp);
43 ASSERT (gs.i == (unsigned int) gp);
44 ASSERT (gs.c == (unsigned char) gp);
45 ASSERT (gs.l == (unsigned long) gp);
47 ASSERT (lc == (unsigned char) lp);
48 ASSERT (li == (unsigned int) lp);
49 ASSERT (ll == (unsigned long) lp);
51 #ifndef __SDCC_pdk14 // Not enough RAM
52 ASSERT (ls.i == (unsigned int) lp);
53 ASSERT (ls.c == (unsigned char) lp);
54 ASSERT (ls.l == (unsigned long) lp);
55 #endif
56 #endif // __SDCC