aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorEdmund Grimley Evans <Edmund.Grimley.Evans@gmail.com>2015-11-21 23:58:58 +0000
committerEdmund Grimley Evans <Edmund.Grimley.Evans@gmail.com>2015-11-21 23:58:58 +0000
commit737f9842138aca6e4b6f44e26773288bb4dccd58 (patch)
treeee2094741963fc8bdbc6a7e46bb78ea994965c09 /tccgen.c
parentcfef9ac3f53bf46a0283ae427810d1d950661016 (diff)
downloadtinycc-737f9842138aca6e4b6f44e26773288bb4dccd58.tar.gz
tinycc-737f9842138aca6e4b6f44e26773288bb4dccd58.tar.bz2
tccgen.c: Bug fix for 992cbda and 3ff77a1: set nocode_wanted.
tests/tests2/78_vla_label.*: Add test.
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c34
1 files changed, 26 insertions, 8 deletions
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) {