struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3560.c
bloba63c88bc575a514ff4d671e5bd2f13e2d5e308a9
1 /* bug-3560.c
2 A bug caused by an over-eager loop optimization.
3 */
5 #include <testfwk.h>
7 #pragma disable_warning 85
9 #include <stdint.h>
11 typedef enum { haut, bas, gauche, droite, entree} touche;
13 uint8_t key;
14 volatile uint8_t Control_1;
15 volatile uint8_t next;
17 void depl(uint16_t touche, uint8_t* end_piece)
19 ASSERT (!*end_piece);
20 *end_piece = 1;
21 Control_1 = (key >> 1);
24 uint8_t possible (uint8_t * pce)
26 return key;
29 void mygame()
32 uint8_t end_piece;
33 uint8_t end_game=0;
35 while(! end_game)
39 end_piece = 0;
40 key = Control_1;
42 if (!(key & 0b00000010))
43 depl(bas, &end_piece);
44 else if (!(key & 0b00001000))
45 depl(droite, &end_piece);
46 else if (!(key & 0b00000100))
47 depl(gauche, &end_piece);
49 while(!end_piece);
50 end_game= (!possible(&next));
54 void
55 testBug(void)
57 Control_1 = 0b00000111;
58 mygame();