From ff3f9aa6ba4a2f56a3cb0c4532ce0460c834ba6d Mon Sep 17 00:00:00 2001 From: Edmund Grimley Evans Date: Fri, 20 Feb 2015 23:16:00 +0000 Subject: [PATCH] Fix handling of case_reg in switch statement. The back end functions gen_op(comparison) and gtst() might allocate registers so case_reg should be left on the value stack while they are called and set again afterwards. --- tccgen.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tccgen.c b/tccgen.c index d456a2a..510051a 100644 --- a/tccgen.c +++ b/tccgen.c @@ -4883,6 +4883,7 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, b = gjmp(0); gsym(*case_sym); vseti(case_reg, 0); + vdup(); vpushi(v1); if (v1 == v2) { gen_op(TOK_EQ); @@ -4895,6 +4896,8 @@ static void block(int *bsym, int *csym, int *case_sym, int *def_sym, gen_op(TOK_LE); *case_sym = gtst(1, *case_sym); } + case_reg = gv(RC_INT); + vpop(); gsym(b); skip(':'); is_expr = 0;