Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-895992.c
blob8492327b8785a38891d48a21348cca02ea43378a
1 /* bug-895992.c
3 Life Range problem with
4 - uninitialized variable
5 - loop
6 - conditional block
8 LR problem hits all ports, but this test is mcs51 specific
9 */
10 #include <testfwk.h>
12 char p0 = 2;
13 unsigned short loops;
15 static void
16 wait (void)
18 long i, j;
20 /* just clobber all registers: */
21 for (i = 0; i < 2; ++i)
22 for (j = 0; j < 2; ++j)
26 #if !defined(PORT_HOST)
27 # pragma disable_warning 84
28 #endif
30 static void
31 testLR (void)
33 unsigned char number;
34 unsigned char start = 1;
35 unsigned char i;
39 for (i = 1; i > 0 ; i--)
40 wait (); /* destroys all registers */
41 if (start)
43 number = p0;
44 start = 0;
46 number--; /* 'number' might be used before initialization */
47 /* the life range of 'number' must be extended to */
48 /* the whole loop _including_ the conditional block */
49 ++loops;
51 while (number != 0);
53 ASSERT (loops == p0);