History

tccgen.c: Bug fix for 992cbda and 3ff77a1: set nocode_wanted.

tests/tests2/78_vla_label.*: Add test.

Edmund Grimley Evans committed 10 years ago

Commit 737f9841 parent cfef9ac3 files · +39 −8Browse files

Unified · Split

3 files
  1. tccgen.c +26 −8
  2. tests/tests2/78_vla_label.c +9 −0
  3. tests/tests2/78_vla_label.expect +4 −0
tccgen.c+26−8
@@ -4468,8 +4468,11 @@ static void expr_land(void) · 4467 unmodified lines
44684468 expr_land();
44694469 gen_cast(&ctb);
44704470 } else {
4471+ int saved_nocode_wanted = nocode_wanted;
4472+ nocode_wanted = 1;
44714473 expr_land();
44724474 vpop();
4475+ nocode_wanted = saved_nocode_wanted;
44734476 }
44744477 gen_cast(&cti);
44754478 } else {
@@ -4499,8 +4502,11 @@ static void expr_lor(void) · 23 unmodified lines
44994502 next();
45004503 gen_cast(&ctb);
45014504 if (vtop->c.i) {
4505+ int saved_nocode_wanted = nocode_wanted;
4506+ nocode_wanted = 1;
45024507 expr_lor();
45034508 vpop();
4509+ nocode_wanted = saved_nocode_wanted;
45044510 } else {
45054511 vpop();
45064512 expr_lor();
@@ -4533,6 +4539,7 @@ static void expr_cond(void) · 26 unmodified lines
45334539 if (tok == '?') {
45344540 next();
45354541 if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
4542+ int saved_nocode_wanted = nocode_wanted;
45364543 CType boolean;
45374544 int c;
45384545 boolean.t = VT_BOOL;
@@ -4540,16 +4547,27 @@ static void expr_cond(void) · 1 unmodified line
45404547 gen_cast(&boolean);
45414548 c = vtop->c.i;
45424549 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();
45484558 vpop();
4549− skip(':');
4550− expr_cond();
4551− if (c)
4559+ nocode_wanted = saved_nocode_wanted;
4560+ } else {
45524561 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+ }
45534571 }
45544572 else {
45554573 if (vtop != vstack) {
tests/tests2/78_vla_label.c+9−0
@@ -27,10 +27,19 @@ void f2(void) · 26 unmodified lines
2727 }
2828 }
2929
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+
3038 int main()
3139 {
3240 f1(2);
3341 f2();
42+ f3();
3443
3544 return 0;
3645 }
tests/tests2/78_vla_label.expect+4−0
@@ -1,2 +1,6 @@
11 boom!
22 boom!
3+11
4+12
5+0
6+1

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