struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3066.c
blob2cbc3287b54c37aa95032d8a7d66ff2e451fa167
1 /* bug-3066.c
2 Pointer in register overwritten in the z80 backend when using --reserve-regs-iy.
3 */
5 #include <testfwk.h>
7 #include <stdint.h>
9 typedef uint16_t atom;
11 struct node {
12 atom lhs;
13 atom rhs;
16 #define MAX_NODES 10
18 static struct node nodes[MAX_NODES];
19 uint16_t node_freelist = 0;
21 atom alloc_node(atom lhsval, atom rhsval)
23 atom a = node_freelist;
24 node_freelist = nodes[a].lhs;
25 nodes[a].lhs = lhsval;
26 nodes[a].rhs = rhsval;
27 return a;
30 void testBug(void)
32 nodes[0].lhs = 23;
34 atom a = alloc_node(0xa5a5, 0x5a5a);
36 ASSERT (nodes[0].lhs == 0xa5a5);
37 ASSERT (nodes[0].rhs == 0x5a5a);
38 ASSERT (node_freelist == 23);