tests/tests2/78_vla_label.*: Add test.
Unified · Split
| @@ -4468,8 +4468,11 @@ static void expr_land(void) · 4467 unmodified lines | ||
| 4468 | 4468 | expr_land(); |
| 4469 | 4469 | gen_cast(&ctb); |
| 4470 | 4470 | } else { |
| 4471 | + int saved_nocode_wanted = nocode_wanted; | |
| 4472 | + nocode_wanted = 1; | |
| 4471 | 4473 | expr_land(); |
| 4472 | 4474 | vpop(); |
| 4475 | + nocode_wanted = saved_nocode_wanted; | |
| 4473 | 4476 | } |
| 4474 | 4477 | gen_cast(&cti); |
| 4475 | 4478 | } else { |
| @@ -4499,8 +4502,11 @@ static void expr_lor(void) · 23 unmodified lines | ||
| 4499 | 4502 | next(); |
| 4500 | 4503 | gen_cast(&ctb); |
| 4501 | 4504 | if (vtop->c.i) { |
| 4505 | + int saved_nocode_wanted = nocode_wanted; | |
| 4506 | + nocode_wanted = 1; | |
| 4502 | 4507 | expr_lor(); |
| 4503 | 4508 | vpop(); |
| 4509 | + nocode_wanted = saved_nocode_wanted; | |
| 4504 | 4510 | } else { |
| 4505 | 4511 | vpop(); |
| 4506 | 4512 | expr_lor(); |
| @@ -4533,6 +4539,7 @@ static void expr_cond(void) · 26 unmodified lines | ||
| 4533 | 4539 | if (tok == '?') { |
| 4534 | 4540 | next(); |
| 4535 | 4541 | if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |
| 4542 | + int saved_nocode_wanted = nocode_wanted; | |
| 4536 | 4543 | CType boolean; |
| 4537 | 4544 | int c; |
| 4538 | 4545 | boolean.t = VT_BOOL; |
| @@ -4540,16 +4547,27 @@ static void expr_cond(void) · 1 unmodified line | ||
| 4540 | 4547 | gen_cast(&boolean); |
| 4541 | 4548 | c = vtop->c.i; |
| 4542 | 4549 | vpop(); |
| 4543 | − if (tok != ':' || !gnu_ext) { | |
| 4544 | − vpop(); | |
| 4545 | − gexpr(); | |
| 4546 | − } | |
| 4547 | − if (!c) | |
| 4550 | + if (c) { | |
| 4551 | + if (tok != ':' || !gnu_ext) { | |
| 4552 | + vpop(); | |
| 4553 | + gexpr(); | |
| 4554 | + } | |
| 4555 | + skip(':'); | |
| 4556 | + nocode_wanted = 1; | |
| 4557 | + expr_cond(); | |
| 4548 | 4558 | vpop(); |
| 4549 | − skip(':'); | |
| 4550 | − expr_cond(); | |
| 4551 | − if (c) | |
| 4559 | + nocode_wanted = saved_nocode_wanted; | |
| 4560 | + } else { | |
| 4552 | 4561 | vpop(); |
| 4562 | + if (tok != ':' || !gnu_ext) { | |
| 4563 | + nocode_wanted = 1; | |
| 4564 | + gexpr(); | |
| 4565 | + vpop(); | |
| 4566 | + nocode_wanted = saved_nocode_wanted; | |
| 4567 | + } | |
| 4568 | + skip(':'); | |
| 4569 | + expr_cond(); | |
| 4570 | + } | |
| 4553 | 4571 | } |
| 4554 | 4572 | else { |
| 4555 | 4573 | if (vtop != vstack) { |
| @@ -27,10 +27,19 @@ void f2(void) · 26 unmodified lines | ||
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | +void f3(void) | |
| 31 | +{ | |
| 32 | + printf("%d\n", 0 ? printf("x1\n") : 11); | |
| 33 | + printf("%d\n", 1 ? 12 : printf("x2\n")); | |
| 34 | + printf("%d\n", 0 && printf("x3\n")); | |
| 35 | + printf("%d\n", 1 || printf("x4\n")); | |
| 36 | +} | |
| 37 | + | |
| 30 | 38 | int main() |
| 31 | 39 | { |
| 32 | 40 | f1(2); |
| 33 | 41 | f2(); |
| 42 | + f3(); | |
| 34 | 43 | |
| 35 | 44 | return 0; |
| 36 | 45 | } |
| @@ -1,2 +1,6 @@ | ||
| 1 | 1 | boom! |
| 2 | 2 | boom! |
| 3 | +11 | |
| 4 | +12 | |
| 5 | +0 | |
| 6 | +1 | |