aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-01-24 14:27:36 +0100
committerLars Knoll <lars.knoll@digia.com>2013-01-24 14:46:12 +0100
commit08897e64c866fbf283e7cf434a4db0a5ae1f13a7 (patch)
treeeb8057f74958560c1df6ddfbddc7a1636502b1cd
parent4e4fb0ced23391c4ffb1b59845d94e6c658d3deb (diff)
Fix return statement outside of function body
Such a program is syntactically incorrect Change-Id: Ica23c67aae55890a36064987f6019d9d7f50585e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
-rw-r--r--qv4codegen.cpp2
-rw-r--r--tests/TestExpectations12
2 files changed, 3 insertions, 11 deletions
diff --git a/qv4codegen.cpp b/qv4codegen.cpp
index 56783738b8..dfc855ba2c 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 e6a473f207..311f3c9e40 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