struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2320.c
blob5a4a916b2f12514c2ef71b232bf62573abf1117a
1 /*
2 bug-2320.c z80 codegen / regalloc interaction issue overwriting register h
3 */
5 #include <testfwk.h>
7 #pragma disable_warning 85
8 #pragma disable_warning 283
10 void as(char *c1, const char *c2, unsigned int i)
12 ASSERT(0);
15 extern void p(char *c,...)
17 ASSERT(0);
20 #define a(x) ((x) == 0 ? as(#x, __FILE__, __LINE__):(void)0)
22 #define BACKING_STORAGE_SIZE 8192
23 char *buffer;
24 #define buffer_size (BACKING_STORAGE_SIZE-2)
25 unsigned buffer_p, buffer_len;
26 char *buffer_gap;
28 void buffer_invariants()
30 a(buffer_len <= buffer_size);
31 a(buffer_p <= buffer_len);
33 if (buffer_gap != buffer + buffer_size - buffer_len + buffer_p) {
34 p("%04x + %04x - %04x + %04x = %04x, not %04x\n",
35 buffer, buffer_size, buffer_len, buffer_p,
36 buffer + buffer_size - buffer_len + buffer_p,
37 buffer_gap);
38 a(buffer_gap == buffer + buffer_size - buffer_len + buffer_p);
42 void testBug(void)
44 buffer = (unsigned char __xdata *)(0xa5a5);
45 buffer_len = 1;
46 buffer_p = 0;
47 buffer_gap = buffer + buffer_size - buffer_len + buffer_p;
48 buffer_invariants();