struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-pr39339.c
blob79ddb73d22e33769580aceda59488f53fe45b276
1 /*
2 pr39339.c from the execute part of the gcc torture tests.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 #include <string.h>
13 struct C
15 unsigned int c;
16 struct D
18 unsigned int columns : 4;
19 unsigned int fore : 12;
20 unsigned int back : 6;
21 unsigned int fragment : 1;
22 unsigned int standout : 1;
23 unsigned int underline : 1;
24 unsigned int strikethrough : 1;
25 unsigned int reverse : 1;
26 unsigned int blink : 1;
27 unsigned int half : 1;
28 unsigned int bold : 1;
29 unsigned int invisible : 1;
30 unsigned int pad : 1;
31 } attr;
34 struct A
36 struct C *data;
37 unsigned int len;
40 struct B
42 struct A *cells;
43 unsigned char soft_wrapped : 1;
46 struct E
48 long row, col;
49 struct C defaults;
52 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pic14) // Lack of memory
53 void foo (struct E *screen, unsigned int c, int columns, struct B *row)
55 struct D attr;
56 long col;
57 int i;
58 col = screen->col;
59 attr = screen->defaults.attr;
60 attr.columns = columns;
61 row->cells->data[col].c = c;
62 row->cells->data[col].attr = attr;
63 col++;
64 attr.fragment = 1;
65 for (i = 1; i < columns; i++)
67 row->cells->data[col].c = c;
68 row->cells->data[col].attr = attr;
69 col++;
72 #endif
74 void
75 testTortureExecute (void)
77 #if !defined(__SDCC_pdk14) && !defined(__SDCC_pic14) // Lack of memory
78 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
79 struct E e = {.row = 5,.col = 0,.defaults =
80 {6, {-1, -1, -1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}} };
81 struct C c[4];
82 struct A a = { c, 4 };
83 struct B b = { &a, 1 };
84 struct D d;
85 memset (&c, 0, sizeof c);
86 foo (&e, 65, 2, &b);
87 d = e.defaults.attr;
88 d.columns = 2;
89 if (memcmp (&d, &c[0].attr, sizeof d))
90 ASSERT (0);
91 d.fragment = 1;
92 if (memcmp (&d, &c[1].attr, sizeof d))
93 ASSERT (0);
94 return;
95 #endif
96 #endif