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.
master
Edmund Grimley Evans 2015-02-20 23:16:00 +00:00
parent a6c3ce6ec0
commit ff3f9aa6ba
1 changed files with 3 additions and 0 deletions

View File

@ -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;