Imported Upstream version 2.9.0
[debian/cc1111] / support / regression / tests / bug-971834.c
1 /* bug-971834.c
2
3    Life Range problem with
4    - uninitialized variable
5    - loop
6
7    LR problem hits all ports, but this test is mcs51 specific
8  */
9
10 #include <testfwk.h>
11
12 unsigned char ttt[] = {0xff, 1};
13 unsigned char b;
14
15 #if !defined(PORT_HOST)
16 #  pragma disable_warning 84
17 #endif
18
19 unsigned char orsh (void)
20 {
21   unsigned char a, i;
22   for (i = 0; i < sizeof(ttt); i++)
23     a |= ttt[i];
24   return a;
25 }
26
27 unsigned char orsh1 (void)
28 {
29   unsigned char i, j;
30   unsigned char a;
31   for (j = 0; j < sizeof(ttt); j++)
32     {
33       for (i = 0; i < sizeof(ttt); i++)
34         {
35           a |= ttt[i];
36           b = a;
37         }
38     }
39   return b;
40 }
41
42 void
43 testLR(void)
44 {
45   ASSERT(orsh()  == 0xff);
46   ASSERT(orsh1() == 0xff);
47 }