From 70f0a25864e74b6778bf1603684d36fff6e20bcc Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 4 Jan 2013 09:59:04 +0100 Subject: 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 --- qv4codegen.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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->statement) || AST::cast(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); -- cgit v1.2.3