aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2018-10-11 13:52:49 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2018-11-16 09:47:22 +0000
commit0d3eccd2a982faa46e8515cd5c55f95adcc5f868 (patch)
tree18167761df94398562fb6ab52f82d07de1f05e4e
parentf92c48a231d5f98513e649340652baaf01f327ad (diff)
Stop codegen after error
We won't use the bytecode anyway, and it prevents consistency checks that come after the error from failing. Specifically: there might be jumps that have no label defined. Fixes: QTBUG-71738 Change-Id: I62a7e943b0156d42caccfa40507853de79e3b1ce Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit c4f82e59d5e9bd3df37c3f08657beb2aeac53161) Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/qml/compiler/qv4codegen.cpp20
-rw-r--r--tests/auto/qml/v4misc/tst_v4misc.cpp1
2 files changed, 12 insertions, 9 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 7307ee3bd8..1f59ccbef2 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -2206,15 +2206,17 @@ int Codegen::defineFunction(const QString &name, AST::Node *ast,
bytecodeGenerator->addInstruction(Instruction::Ret());
}
- bytecodeGenerator->finalize(_context);
- _context->registerCount = bytecodeGenerator->registerCount();
- static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE");
- if (showCode) {
- qDebug() << "=== Bytecode for" << _context->name << "strict mode" << _context->isStrict
- << "register count" << _context->registerCount;
- QV4::Moth::dumpBytecode(_context->code, _context->locals.size(), _context->arguments.size(),
- _context->line, _context->lineNumberMapping);
- qDebug();
+ if (!hasError) {
+ bytecodeGenerator->finalize(_context);
+ _context->registerCount = bytecodeGenerator->registerCount();
+ static const bool showCode = qEnvironmentVariableIsSet("QV4_SHOW_BYTECODE");
+ if (showCode) {
+ qDebug() << "=== Bytecode for" << _context->name << "strict mode" << _context->isStrict
+ << "register count" << _context->registerCount;
+ QV4::Moth::dumpBytecode(_context->code, _context->locals.size(), _context->arguments.size(),
+ _context->line, _context->lineNumberMapping);
+ qDebug();
+ }
}
qSwap(_returnAddress, returnAddress);
diff --git a/tests/auto/qml/v4misc/tst_v4misc.cpp b/tests/auto/qml/v4misc/tst_v4misc.cpp
index ff9d41805f..c157a462f8 100644
--- a/tests/auto/qml/v4misc/tst_v4misc.cpp
+++ b/tests/auto/qml/v4misc/tst_v4misc.cpp
@@ -235,6 +235,7 @@ void tst_v4misc::parserMisc_data()
QTest::addColumn<QString>("error");
QTest::newRow("8[++i][+++i]") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference.");
+ QTest::newRow("T||9[---L6i]") << QString("ReferenceError: Prefix ++ operator applied to value that is not a reference.");
}
void tst_v4misc::parserMisc()