diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-01-04 09:59:04 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2013-01-04 12:00:15 +0100 |
commit | 70f0a25864e74b6778bf1603684d36fff6e20bcc (patch) | |
tree | 930cc86da0fa57b51a0e89437b4b80440d285447 | |
parent | dcc4275e667a57b423a6799a7aecf47438878237 (diff) |
Produce a syntax error when a break appears outside of an iteration
Fixes expected failure of ch12/12.8/S12.8_A1_T2 and others
Change-Id: I261d649f6a29bbd6debfca35e7ccaf1a0a7006b9
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r-- | qv4codegen.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/qv4codegen.cpp b/qv4codegen.cpp index fe754a435c..190c0dcf63 100644 --- a/qv4codegen.cpp +++ b/qv4codegen.cpp @@ -1927,6 +1927,8 @@ bool Codegen::visit(Block *ast) bool Codegen::visit(BreakStatement *ast) { + if (!_loop) + throwSyntaxError(ast->lastSourceLocation(), QCoreApplication::translate("qv4codegen", "Break outside of loop")); unwindException(_loop->tryCleanup); if (ast->label.isEmpty()) _block->JUMP(_loop->breakBlock); @@ -2104,7 +2106,7 @@ bool Codegen::visit(LabelledStatement *ast) AST::cast<AST::LocalForStatement *>(ast->statement) || AST::cast<AST::LocalForEachStatement *>(ast->statement)) { statement(ast->statement); // labelledStatement will be associated with the ast->statement's loop. - } else { + } else if (_loop) { IR::BasicBlock *breakBlock = _function->newBasicBlock(); enterLoop(ast->statement, breakBlock, /*continueBlock*/ 0); statement(ast->statement); |