History

tccgen.c: Recognise constant expressions with conditional operator.

tests/tests2/78_vla_label.c: Check that int a[1 ? 1 : 1] is not a VLA.

Edmund Grimley Evans committed 10 years ago

Commit 992cbda1 parent 30c54c92 files · +21 −10Browse files

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t