aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-07 11:28:36 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-07 10:32:08 +0000
commitfb2f71137829ba14b2d102ace0e36063daf034a9 (patch)
tree83f92d1836e5a0a71ec4e11a67910b944cf42954
parent06e0ec7cfc6e990c1101a2b4c15452d3c10b6816 (diff)
Don't evaluate the switch expression inside the switch block
Change-Id: I6cbe0610b65c9f9d7381bc1c70ae17e10486d5c3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/qml/compiler/qv4codegen.cpp4
-rw-r--r--tests/auto/qml/ecmascripttests/TestExpectations2
2 files changed, 2 insertions, 4 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 09f08e8bf2..c90787acc8 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -3435,8 +3435,6 @@ bool Codegen::visit(SwitchStatement *ast)
RegisterScope scope(this);
if (ast->block) {
- ControlFlowBlock controlFlow(this, ast->block);
-
BytecodeGenerator::Label switchEnd = bytecodeGenerator->newLabel();
Reference lhs = expression(ast->expression);
@@ -3444,6 +3442,8 @@ bool Codegen::visit(SwitchStatement *ast)
return false;
lhs = lhs.storeOnStack();
+ ControlFlowBlock controlFlow(this, ast->block);
+
// set up labels for all clauses
QHash<Node *, BytecodeGenerator::Label> blockMap;
for (CaseClauses *it = ast->block->clauses; it; it = it->next)
diff --git a/tests/auto/qml/ecmascripttests/TestExpectations b/tests/auto/qml/ecmascripttests/TestExpectations
index a70a97bfb9..ac311add31 100644
--- a/tests/auto/qml/ecmascripttests/TestExpectations
+++ b/tests/auto/qml/ecmascripttests/TestExpectations
@@ -1017,8 +1017,6 @@ language/statements/let/block-local-closure-set-before-initialization.js fails
language/statements/let/function-local-closure-set-before-initialization.js fails
language/statements/let/global-closure-set-before-initialization.js fails
language/statements/return/tco.js strictFails
-language/statements/switch/scope-lex-open-case.js fails
-language/statements/switch/scope-lex-open-dflt.js fails
language/statements/switch/tco-case-body-dflt.js strictFails
language/statements/switch/tco-case-body.js strictFails
language/statements/switch/tco-dftl-body.js strictFails