* src/SDCCast.c (decorateType): fix promotion of unary minus
[fw/sdcc] / support / regression / tests / bug-221100.c
1 /* bug-221100.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 #ifdef __mcs51
9 xdata
10 #endif
11 static unsigned int
12 testArray[130];
13
14 static unsigned int test_int ; 
15 static unsigned char test_index ; 
16
17 static void 
18 fetch(void) 
19
20   test_int = testArray [test_index] ; 
21
22
23 static void
24 testUnsignedCharIndex(void)
25 {
26   int i;
27   for (i = 0; i < 130; i++) {
28     testArray[i] = i;
29   }
30
31   test_index = 5;
32   fetch();
33   ASSERT(test_int == 5);
34
35   test_index = 129;
36   fetch();
37   ASSERT(test_int == 129);
38 }