aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2016-09-04 05:17:08 +0200
committerMichael Matz <matz@suse.de>2016-12-15 17:47:11 +0100
commit1602998751c8de219514af271a3925b69a6570fb (patch)
tree5a1c64d03af9ae1bdbf0f879a9ed40e6fa74cccf /tccgen.c
parentf2a071e808db2896823463089531e08d0b2d0ee8 (diff)
downloadtinycc-1602998751c8de219514af271a3925b69a6570fb.tar.gz
tinycc-1602998751c8de219514af271a3925b69a6570fb.tar.bz2
Fix more nocode_wanted jump problems
In statement expression we really mustn't emit backward jumps under nocode_wanted (they will form infinte loops as no expressions are evaluated). Do-while and explicit loop with gotos weren't handled.
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/tccgen.c b/tccgen.c
index 1dc5864..53ce185 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -5605,8 +5605,9 @@ static void block(int *bsym, int *csym, int is_expr)
skip('(');
gsym(b);
gexpr();
- c = gvtst(0, 0);
- gsym_addr(c, d);
+ c = gvtst(0, 0);
+ if (!nocode_wanted)
+ gsym_addr(c, d);
skip(')');
gsym(a);
skip(';');
@@ -5678,7 +5679,10 @@ static void block(int *bsym, int *csym, int is_expr)
gexpr();
if ((vtop->type.t & VT_BTYPE) != VT_PTR)
expect("pointer");
- ggoto();
+ if (!nocode_wanted)
+ ggoto();
+ else
+ vtop--;
} else if (tok >= TOK_UIDENT) {
s = label_find(tok);
/* put forward definition if needed */
@@ -5689,7 +5693,9 @@ static void block(int *bsym, int *csym, int is_expr)
s->r = LABEL_FORWARD;
}
vla_sp_restore_root();
- if (s->r & LABEL_FORWARD)
+ if (nocode_wanted)
+ ;
+ else if (s->r & LABEL_FORWARD)
s->jnext = gjmp(s->jnext);
else
gjmp_addr(s->jnext);