struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3779.c
blobbf4a58f1b91711707d0039a8d5e6e61dbb29b762
1 /** bug-3779.c: code generation for sm83 could store a temporary in l, then set up hl for stack access, overwriting the temporary.
2 */
4 #include <testfwk.h>
6 struct State {
7 unsigned short a;
8 unsigned char b;
9 };
10 static struct State state;
12 static char glob_var;
14 #ifdef __SDCC_sm83
15 static __sfr __at(0xff00) reg; // Use LCD control register for this test, since all its bits are read/write.
16 #else
17 unsigned char reg;
18 #endif
20 void m(void)
22 state.b = 0;
24 if (glob_var) {
25 if (glob_var) {
26 state.a += 1;
28 if (glob_var) {
29 state.b = 0;
32 unsigned char foo = state.a >> 1;
33 foo -= reg;
34 reg = foo;
38 void testBug(void)
40 reg = 0x00;
41 glob_var = 1;
42 state.a = 1;
43 m();
44 ASSERT(reg == 1);