Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-2448.c
blob78f0633da116492c62d6221657231ccbc55e597a
1 /*
2 bug-2448.c
3 */
5 #include <testfwk.h>
7 typedef unsigned char BYTE;
8 typedef unsigned int WORD;
10 volatile BYTE MYDAT[8];
12 #define MAKEWORD(msb, lsb) (((WORD) (msb) << 8) | (lsb))
14 #define SETUP_VALUE() MAKEWORD (MYDAT[3], MYDAT[2])
15 #define SETUP_INDEX() MAKEWORD (MYDAT[5], MYDAT[4])
16 #define SETUP_LENGTH() MAKEWORD (MYDAT[7], MYDAT[6])
18 WORD badfunc (BYTE cmd)
20 WORD val = SETUP_VALUE();
21 WORD idx = SETUP_INDEX();
22 WORD len = SETUP_LENGTH();
23 volatile WORD r = val + idx + len;
25 if (cmd == 0)
26 return len;
27 else
28 return 0;
31 void testBug (void)
33 MYDAT[2] = 10; // val
34 MYDAT[3] = 0;
35 MYDAT[4] = 11; // idx
36 MYDAT[5] = 0;
37 MYDAT[6] = 12; // len
38 MYDAT[7] = 0;
40 ASSERT (badfunc (0) == 12);
41 ASSERT (badfunc (1) == 0);