jscript: Fixed empty cases in the end of switch statement.

This commit is contained in:
Jacek Caban 2012-09-04 15:52:27 +02:00 committed by Alexandre Julliard
parent a1e6835d0e
commit 6ba7a1964a
2 changed files with 40 additions and 6 deletions

View file

@ -1540,18 +1540,26 @@ static HRESULT compile_switch_statement(compiler_ctx_t *ctx, switch_statement_t
set_arg_uint(ctx, iter->expr ? case_jmps[i++] : default_jmp, ctx->code_off);
for(stat_iter = iter->stat; stat_iter && (!iter->next || iter->next->stat != stat_iter); stat_iter = stat_iter->next) {
hres = compile_statement(ctx, &stat_ctx, stat_iter);
if(iter->stat) {
for(stat_iter = iter->stat; stat_iter && (!iter->next || iter->next->stat != stat_iter);
stat_iter = stat_iter->next) {
hres = compile_statement(ctx, &stat_ctx, stat_iter);
if(FAILED(hres))
break;
if(stat_iter->next && !push_instr(ctx, OP_pop)) {
hres = E_OUTOFMEMORY;
break;
}
}
if(FAILED(hres))
break;
if(stat_iter->next && !push_instr(ctx, OP_pop)) {
}else {
if(!push_instr(ctx, OP_undefined)) {
hres = E_OUTOFMEMORY;
break;
}
}
if(FAILED(hres))
break;
}
heap_free(case_jmps);

View file

@ -757,6 +757,32 @@ case 3:
ok(false, "unexpected case 3");
}
switch(1) {
case 2:
ok(false, "unexpected case 2");
break;
default:
/* empty default */
}
switch(2) {
default:
ok(false, "unexpected default");
break;
case 2:
/* empty case */
};
switch(2) {
default:
ok(false, "unexpected default");
break;
case 1:
case 2:
case 3:
/* empty case */
};
(function() {
var i=0;