struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2089.c
blobe5189fcb62ae911af31560652b60f3265e4f0c18
1 /*
2 bug-2089.c
3 */
5 #include <testfwk.h>
6 #include <string.h>
8 struct t0_t {
9 const char *p2;
10 char v2[5];
13 struct t1_t {
14 const char *p0;
15 char v0[5];
16 const char *p1;
17 char v1[5];
18 struct t0_t t;
21 struct t1_t w0 = {"11", "22", "33", "44", {"55", "66"}};
22 const struct t1_t w1 = {"11", "22", "33", "44", {"55", "66"}};
24 const char p0[] = {'1', '1', 0, 0, 0};
25 const char v0[] = {'2', '2', 0, 0, 0};
26 const char p1[] = {'3', '3', 0, 0, 0};
27 const char v1[] = {'4', '4', 0, 0, 0};
28 const char p2[] = {'5', '5', 0, 0, 0};
29 const char v2[] = {'6', '6', 0, 0, 0};
31 void testBug (void)
33 ASSERT (strcmp (w0.p0, p0) == 0);
34 ASSERT (strcmp (w0.p1, p1) == 0);
35 ASSERT (strcmp (w0.t.p2, p2) == 0);
37 ASSERT (memcmp (w0.v0, v0, sizeof (v0)) == 0);
38 ASSERT (memcmp (w0.v1, v1, sizeof (v1)) == 0);
39 ASSERT (memcmp (w0.t.v2, v2, sizeof (v2)) == 0);
41 ASSERT (strcmp (w1.p0, p0) == 0);
42 ASSERT (strcmp (w1.p1, p1) == 0);
43 ASSERT (strcmp (w1.t.p2, p2) == 0);
45 ASSERT (memcmp (w1.v0, v0, sizeof (v0)) == 0);
46 ASSERT (memcmp (w1.v1, v1, sizeof (v1)) == 0);
47 ASSERT (memcmp (w1.t.v2, v2, sizeof (v2)) == 0);