blob: 2cbc3287b54c37aa95032d8a7d66ff2e451fa167 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/* bug-3066.c
Pointer in register overwritten in the z80 backend when using --reserve-regs-iy.
*/
#include <testfwk.h>
#include <stdint.h>
typedef uint16_t atom;
struct node {
atom lhs;
atom rhs;
};
#define MAX_NODES 10
static struct node nodes[MAX_NODES];
uint16_t node_freelist = 0;
atom alloc_node(atom lhsval, atom rhsval)
{
atom a = node_freelist;
node_freelist = nodes[a].lhs;
nodes[a].lhs = lhsval;
nodes[a].rhs = rhsval;
return a;
}
void testBug(void)
{
nodes[0].lhs = 23;
atom a = alloc_node(0xa5a5, 0x5a5a);
ASSERT (nodes[0].lhs == 0xa5a5);
ASSERT (nodes[0].rhs == 0x5a5a);
ASSERT (node_freelist == 23);
}
|