From 08897e64c866fbf283e7cf434a4db0a5ae1f13a7 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 24 Jan 2013 14:27:36 +0100 Subject: [PATCH] Fix return statement outside of function body Such a program is syntactically incorrect Change-Id: Ica23c67aae55890a36064987f6019d9d7f50585e Reviewed-by: Lars Knoll --- qv4codegen.cpp | 2 ++ tests/TestExpectations | 12 +----------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/qv4codegen.cpp b/qv4codegen.cpp index 5678373..dfc855b 100644 --- a/qv4codegen.cpp +++ b/qv4codegen.cpp @@ -2289,6 +2289,8 @@ bool Codegen::visit(LocalForStatement *ast) bool Codegen::visit(ReturnStatement *ast) { + if (_mode == GlobalCode) + throwSyntaxError(ast->returnToken, QCoreApplication::translate("qv4codegen", "Return statement outside of function")); if (ast->expression) { Result expr = expression(ast->expression); move(_block->TEMP(_returnAddress), *expr); diff --git a/tests/TestExpectations b/tests/TestExpectations index e6a473f..311f3c9 100644 --- a/tests/TestExpectations +++ b/tests/TestExpectations @@ -132,14 +132,4 @@ Sbp_A3_T1 failing Sbp_A4_T1 failing Sbp_A4_T2 failing S12.4_A1 failing -S12.9_A1_T1 failing -S12.9_A1_T10 failing -S12.9_A1_T2 failing -S12.9_A1_T3 failing -S12.9_A1_T4 failing -S12.9_A1_T5 failing -S12.9_A1_T6 failing -S12.9_A1_T7 failing -S12.9_A1_T8 failing -S12.9_A1_T9 failing -S15.2.4.4_A14 failing +S15.2.4.4_A14 failing \ No newline at end of file -- 2.7.4