From 737f9842138aca6e4b6f44e26773288bb4dccd58 Mon Sep 17 00:00:00 2001 From: Edmund Grimley Evans Date: Sat, 21 Nov 2015 23:58:58 +0000 Subject: tccgen.c: Bug fix for 992cbda and 3ff77a1: set nocode_wanted. tests/tests2/78_vla_label.*: Add test. --- tccgen.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'tccgen.c') diff --git a/tccgen.c b/tccgen.c index 3b5ad75..4e6a116 100644 --- a/tccgen.c +++ b/tccgen.c @@ -4468,8 +4468,11 @@ static void expr_land(void) expr_land(); gen_cast(&ctb); } else { + int saved_nocode_wanted = nocode_wanted; + nocode_wanted = 1; expr_land(); vpop(); + nocode_wanted = saved_nocode_wanted; } gen_cast(&cti); } else { @@ -4499,8 +4502,11 @@ static void expr_lor(void) next(); gen_cast(&ctb); if (vtop->c.i) { + int saved_nocode_wanted = nocode_wanted; + nocode_wanted = 1; expr_lor(); vpop(); + nocode_wanted = saved_nocode_wanted; } else { vpop(); expr_lor(); @@ -4533,6 +4539,7 @@ static void expr_cond(void) if (tok == '?') { next(); if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { + int saved_nocode_wanted = nocode_wanted; CType boolean; int c; boolean.t = VT_BOOL; @@ -4540,16 +4547,27 @@ static void expr_cond(void) gen_cast(&boolean); c = vtop->c.i; vpop(); - if (tok != ':' || !gnu_ext) { - vpop(); - gexpr(); - } - if (!c) + if (c) { + if (tok != ':' || !gnu_ext) { + vpop(); + gexpr(); + } + skip(':'); + nocode_wanted = 1; + expr_cond(); vpop(); - skip(':'); - expr_cond(); - if (c) + nocode_wanted = saved_nocode_wanted; + } else { vpop(); + if (tok != ':' || !gnu_ext) { + nocode_wanted = 1; + gexpr(); + vpop(); + nocode_wanted = saved_nocode_wanted; + } + skip(':'); + expr_cond(); + } } else { if (vtop != vstack) { -- cgit v1.3.1