nocode_wanted with while/for inside ({})
[tinycc.git] / tests / tests2 / 82_nocode_wanted.c
blob18b491432fe636b2c50482a52e3aa2a5539d563f
1 extern int printf(const char *format, ...);
2 static void kb_wait_1(void)
4 unsigned long timeout = 2;
5 do {
6 (1 ?
7 printf("timeout=%ld\n", timeout) :
8 ({
9 while (1)
10 printf("error\n");
13 timeout--;
14 } while (timeout);
16 static void kb_wait_2(void)
18 unsigned long timeout = 2;
19 do {
20 (1 ?
21 printf("timeout=%ld\n", timeout) :
23 for (;;)
24 printf("error\n");
27 timeout--;
28 } while (timeout);
30 static void kb_wait_3(void)
32 unsigned long timeout = 2;
33 do {
34 (1 ?
35 printf("timeout=%ld\n", timeout) :
37 int i = 1;
38 goto label;
39 i = i + 2;
40 label:
41 i = i + 3;
44 timeout--;
45 } while (timeout);
47 static void kb_wait_4(void)
49 unsigned long timeout = 2;
50 do {
51 (1 ?
52 printf("timeout=%ld\n", timeout) :
54 switch(timeout) {
55 case 2:
56 printf("timeout is 2");
57 break;
58 case 1:
59 printf("timeout is 1");
60 break;
61 default:
62 printf("timeout is 0?");
63 break;
65 // return;
68 timeout--;
69 } while (timeout);
71 int main()
73 printf("begin\n");
74 kb_wait_1();
75 kb_wait_2();
76 kb_wait_3();
77 kb_wait_4();
78 printf("end\n");
79 return 0;