summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-971834.c
blob: 730b8258a312abbed93b466ed7aac4faf1671b7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* bug-971834.c

   Life Range problem with
   - uninitialized variable
   - loop

   LR problem hits all ports, but this test is mcs51 specific
 */

#include <testfwk.h>

unsigned char ttt[] = {0xff, 1};
unsigned char b;

#if !defined(PORT_HOST)
#  pragma disable_warning 84
#endif

unsigned char orsh (void)
{
  unsigned char a, i;
  unsigned char *p = &a;

  a = *p; // to eliminate warnings by llvm
  for (i = 0; i < sizeof(ttt); i++)
    a |= ttt[i];
  return a;
}

unsigned char orsh1 (void)
{
  unsigned char i, j;
  unsigned char a;
  unsigned char *p = &a;

  a = *p; // to eliminate warnings by llvm
  for (j = 0; j < sizeof(ttt); j++)
    {
      for (i = 0; i < sizeof(ttt); i++)
        {
          a |= ttt[i];
          b = a;
        }
    }
  return b;
}

void
testLR(void)
{
  ASSERT(orsh()  == 0xff);
  ASSERT(orsh1() == 0xff);
}