tests/tests2/78_vla_label.c: Check that int a[1 ? 1 : 1] is not a VLA.
Unified · Split
| @@ -4522,9 +4522,13 @@ static void expr_cond(void) · 4521 unmodified lines | ||
| 4522 | 4522 | SValue sv; |
| 4523 | 4523 | CType type, type1, type2; |
| 4524 | 4524 | |
| 4525 | − if (const_wanted) { | |
| 4525 | + if (const_wanted) | |
| 4526 | 4526 | expr_lor_const(); |
| 4527 | − if (tok == '?') { | |
| 4527 | + else | |
| 4528 | + expr_lor(); | |
| 4529 | + if (tok == '?') { | |
| 4530 | + next(); | |
| 4531 | + if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { | |
| 4528 | 4532 | CType boolean; |
| 4529 | 4533 | int c; |
| 4530 | 4534 | boolean.t = VT_BOOL; |
| @@ -4532,7 +4536,6 @@ static void expr_cond(void) · 1 unmodified line | ||
| 4532 | 4536 | gen_cast(&boolean); |
| 4533 | 4537 | c = vtop->c.i; |
| 4534 | 4538 | vpop(); |
| 4535 | − next(); | |
| 4536 | 4539 | if (tok != ':' || !gnu_ext) { |
| 4537 | 4540 | vpop(); |
| 4538 | 4541 | gexpr(); |
| @@ -4544,10 +4547,7 @@ static void expr_cond(void) · 5 unmodified lines | ||
| 4544 | 4547 | if (c) |
| 4545 | 4548 | vpop(); |
| 4546 | 4549 | } |
| 4547 | − } else { | |
| 4548 | − expr_lor(); | |
| 4549 | − if (tok == '?') { | |
| 4550 | − next(); | |
| 4550 | + else { | |
| 4551 | 4551 | if (vtop != vstack) { |
| 4552 | 4552 | /* needed to avoid having different registers saved in |
| 4553 | 4553 | each branch */ |
| @@ -1,8 +1,7 @@ | ||
| 1 | 1 | #include <stdio.h> |
| 2 | 2 | |
| 3 | 3 | /* This test segfaults as of April 27, 2015. */ |
| 4 | − | |
| 5 | −void f(int argc) | |
| 4 | +void f1(int argc) | |
| 6 | 5 | { |
| 7 | 6 | char test[argc]; |
| 8 | 7 | if(0) |
| @@ -13,9 +12,21 @@ void f(int argc) · 4 unmodified lines | ||
| 13 | 12 | goto label; |
| 14 | 13 | } |
| 15 | 14 | |
| 15 | +/* This segfaulted on 2015-11-19. */ | |
| 16 | +void f2(void) | |
| 17 | +{ | |
| 18 | + goto start; | |
| 19 | + { | |
| 20 | + int a[1 ? 1 : 1]; /* not a variable-length array */ | |
| 21 | + start: | |
| 22 | + a[0] = 0; | |
| 23 | + } | |
| 24 | +} | |
| 25 | + | |
| 16 | 26 | int main() |
| 17 | 27 | { |
| 18 | − f(2); | |
| 28 | + f1(2); | |
| 29 | + f2(); | |
| 19 | 30 | |
| 20 | 31 | return 0; |
| 21 | 32 | } |