Imported Upstream version 2.9.0
[debian/cc1111] / support / regression / tests / bug1717943.c
1 /*
2    bug1717943c.c
3      an error in the detection of loopinvariants,
4       will move the foo=0 initialisation out of the loops.
5  */
6
7 #include <testfwk.h>
8
9 char foo, firstcall;
10
11 char check(void)
12 {
13   if(!firstcall)
14     return 1;
15
16   firstcall=0;
17   foo = 42;
18   return 0;
19 }
20
21 void bug(void)
22 {
23   while(1) {
24     foo = 0;
25     while(check())
26       if(check())
27         return;
28   }
29 }
30
31
32 void
33 testBug(void)
34 {
35   firstcall = 1;
36   bug();
37   ASSERT(foo == 0);
38 }