Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug1536762.c
blobf70b4b6073a19d17543ee405a5640716e7c5fec8
1 /*
2 bug1536762.c
3 */
5 #include <testfwk.h>
6 #include <string.h>
7 #include <stdint.h>
9 __xdata uint8_t c = 1;
11 struct d {
12 __xdata struct d *n;
13 uint8_t f;
14 uint8_t s;
15 __xdata uint8_t *buffer;
16 uint16_t length;
20 __xdata struct d xd = {&xd, 1, 0xab, &c, 3};
23 struct {
24 __xdata struct d *c;
25 int16_t count;
26 __xdata uint8_t *bptr;
27 } s = {&xd, -1, &c};
30 void
31 blurb (void)
33 if (s.count < 0)
35 s.c->s = 0xef;
36 s.count = s.c->length - 1;
37 s.bptr = s.c->buffer;
39 *s.bptr = 0;
40 s.bptr++;
41 s.count--;
45 void
46 testBug (void)
48 ASSERT (xd.s == 0xab);
49 ASSERT (s.c->s == 0xab);
51 s.c->s = 0xcd;
53 ASSERT (xd.s == 0xcd);
54 ASSERT (s.c->s == 0xcd);
56 blurb ();
58 ASSERT (xd.s == 0xef);
59 ASSERT (s.c->s == 0xef);
60 ASSERT (c == 0);