* src/SDCCast.c (decorateType): fix promotion of unary minus
[fw/sdcc] / support / regression / tests / bug-477927.c
1 /* Tests an uninitalised variable bug.
2    t is not initalised in all paths in the do loop, causing the while
3    conditional to fail unpredictably.
4
5    Doesn't actually test, is really an example.
6  */
7 #include <testfwk.h>
8
9 typedef unsigned char UBYTE;
10
11 UBYTE
12 randish(void)
13 {
14   static int count;
15
16   if ((++count)&3) {
17     return 1;
18   }
19   else {
20     return 0;
21   }
22 }
23
24 void
25 spoil(UBYTE ignored)
26 {
27   UNUSED(ignored);
28 }
29
30 UBYTE accu[2];
31
32 #if !defined(PORT_HOST)
33 #  pragma save
34 #  pragma disable_warning 84
35 #endif
36
37 void 
38 testLoopInit(void)
39 {
40   UBYTE t, r;
41
42   do {
43     r = randish();
44
45     if(r != 1) {
46       t = ++accu[r];
47       spoil(t);
48     }
49   }
50   while(t != 3);
51 }
52
53 #if !defined(PORT_HOST)
54 #  pragma restore
55 #endif