49f84e76cb2b249ed59a219db7344d26829787cc
[fw/sdcc] / support / regression / tests / bug-751703.c
1 /* bug-751703.c
2
3    If test_index is char, loses high bit when indexes table 
4    workaround is to use [(unsigned int) test_index] 
5  */
6 #include <testfwk.h>
7
8 int x = 1;
9 int y = 2;
10 int z = 0;
11
12 static void
13 addxy(void)
14 {
15   extern int x, y, z;
16   z = x+y;
17
18
19 static void
20 times10x(void)
21 {
22   unsigned char x;
23   
24   z = 0;
25   for (x=0; x<10; x++)
26     {
27       extern int x; /* bind to the global x */
28       z += x;
29     }
30 }
31
32 static void
33 testExternDeadCode(void)
34 {
35   ASSERT(z == 0);
36   addxy();
37   ASSERT(z == 3);
38   times10x();
39   ASSERT(z == 10);
40 }