struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3564.c
blob06a42770adae611f6434c68177d5a6adc24623fe
1 /* bug-3523.c
2 An issue in handling designated initializers where the order of initalization is reversed vs. the order of members.
3 */
5 #include <testfwk.h>
7 typedef struct {
8 char *current;
9 int x;
10 } BlockData1;
12 typedef struct {
13 char *current;
14 int x;
15 long l;
16 } BlockData2;
18 void g1(int i, char *c)
20 ASSERT (i == 110);
21 ASSERT (c == 0);
24 void g2(int i, char *c, long l)
26 ASSERT (i == 110);
27 ASSERT (c == 0);
28 ASSERT (l == 0);
31 void g3(int i, char *c, long l)
33 ASSERT (i == 110);
34 ASSERT (c == 0);
35 ASSERT (l == 42);
38 void g4(int i, char *c, long l)
40 ASSERT (i == 110);
41 ASSERT (c == 0);
42 ASSERT (l == 0);
45 void f1(void)
47 BlockData1 block = { .x = 110, .current = 0 };
49 g1 (block.x, block.current );
52 void f2(void)
54 BlockData2 block = { .x = 110, .current = 0 };
56 g2 (block.x, block.current, block.l );
59 void f3(void)
61 BlockData2 block = { .x = 110, .l = 42 };
63 g3 (block.x, block.current, block.l );
66 void f4(void)
68 BlockData2 block = { .x = 110};
70 g4 (block.x, block.current, block.l );
73 void
74 testBug (void) {
75 f1 ();
76 f2 ();
77 f3 ();
78 f4 ();