a test included.
Unified · Split
| @@ -3848,7 +3848,8 @@ ST_FUNC void unary(void) · 3847 unmodified lines | ||
| 3848 | 3848 | if (const_wanted) |
| 3849 | 3849 | tcc_error("expected constant"); |
| 3850 | 3850 | /* save all registers */ |
| 3851 | − save_regs(0); | |
| 3851 | + if (!nocode_wanted) | |
| 3852 | + save_regs(0); | |
| 3852 | 3853 | /* statement expression : we do not accept break/continue |
| 3853 | 3854 | inside as GCC does */ |
| 3854 | 3855 | block(NULL, NULL, NULL, NULL, 0, 1); |
| @@ -4878,7 +4879,8 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 1023 unmodified lines | ||
| 4878 | 4879 | a = gvtst(1, 0); |
| 4879 | 4880 | b = 0; |
| 4880 | 4881 | block(&a, &b, case_sym, def_sym, case_reg, 0); |
| 4881 | − gjmp_addr(d); | |
| 4882 | + if(!nocode_wanted) | |
| 4883 | + gjmp_addr(d); | |
| 4882 | 4884 | gsym(a); |
| 4883 | 4885 | gsym_addr(b, d); |
| 4884 | 4886 | } else if (tok == '{') { |
| @@ -5070,7 +5072,8 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, · 185 unmodified lines | ||
| 5070 | 5072 | } |
| 5071 | 5073 | skip(')'); |
| 5072 | 5074 | block(&a, &b, case_sym, def_sym, case_reg, 0); |
| 5073 | − gjmp_addr(c); | |
| 5075 | + if(!nocode_wanted) | |
| 5076 | + gjmp_addr(c); | |
| 5074 | 5077 | gsym(a); |
| 5075 | 5078 | gsym_addr(b, c); |
| 5076 | 5079 | scope_stack_bottom = scope_stack_bottom->next; |
| @@ -0,0 +1,80 @@ | ||
| 1 | +extern int printf(const char *format, ...); | |
| 2 | +static void kb_wait_1(void) | |
| 3 | +{ | |
| 4 | + unsigned long timeout = 2; | |
| 5 | + do { | |
| 6 | + (1 ? | |
| 7 | + printf("timeout=%ld\n", timeout) : | |
| 8 | + ({ | |
| 9 | + while (1) | |
| 10 | + printf("error\n"); | |
| 11 | + }) | |
| 12 | + ); | |
| 13 | + timeout--; | |
| 14 | + } while (timeout); | |
| 15 | +} | |
| 16 | +static void kb_wait_2(void) | |
| 17 | +{ | |
| 18 | + unsigned long timeout = 2; | |
| 19 | + do { | |
| 20 | + (1 ? | |
| 21 | + printf("timeout=%ld\n", timeout) : | |
| 22 | + ({ | |
| 23 | + for (;;) | |
| 24 | + printf("error\n"); | |
| 25 | + }) | |
| 26 | + ); | |
| 27 | + timeout--; | |
| 28 | + } while (timeout); | |
| 29 | +} | |
| 30 | +static void kb_wait_3(void) | |
| 31 | +{ | |
| 32 | + unsigned long timeout = 2; | |
| 33 | + do { | |
| 34 | + (1 ? | |
| 35 | + printf("timeout=%ld\n", timeout) : | |
| 36 | + ({ | |
| 37 | + int i = 1; | |
| 38 | + goto label; | |
| 39 | + i = i + 2; | |
| 40 | + label: | |
| 41 | + i = i + 3; | |
| 42 | + }) | |
| 43 | + ); | |
| 44 | + timeout--; | |
| 45 | + } while (timeout); | |
| 46 | +} | |
| 47 | +static void kb_wait_4(void) | |
| 48 | +{ | |
| 49 | + unsigned long timeout = 2; | |
| 50 | + do { | |
| 51 | + (1 ? | |
| 52 | + printf("timeout=%ld\n", timeout) : | |
| 53 | + ({ | |
| 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; | |
| 64 | + }; | |
| 65 | + // return; | |
| 66 | + }) | |
| 67 | + ); | |
| 68 | + timeout--; | |
| 69 | + } while (timeout); | |
| 70 | +} | |
| 71 | +int main() | |
| 72 | +{ | |
| 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; | |
| 80 | +} | |
| @@ -0,0 +1,10 @@ | ||
| 1 | +begin | |
| 2 | +timeout=2 | |
| 3 | +timeout=1 | |
| 4 | +timeout=2 | |
| 5 | +timeout=1 | |
| 6 | +timeout=2 | |
| 7 | +timeout=1 | |
| 8 | +timeout=2 | |
| 9 | +timeout=1 | |
| 10 | +end | |