diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2023-06-21 09:19:16 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-06-21 14:14:39 +0200 |
| commit | dae48cf190c282ef65df94ef7148a93cf3306e2d (patch) | |
| tree | c48a25f66e7d22cd0a1b0a41c522118fab58a8cd /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | 2e1dbd7e0c8081275a92e36a4800c3721c912597 (diff) | |
QmlCompiler: Properly reset before re-running basic blocks pass
If we were within dead code at the end of the previous run we need to
reset the "skip until next label" flag. Otherwise we still assume we're
in dead code at the beginning of the function, with interesting effects.
Pick-to: 6.5 6.6
Fixes: QTBUG-114476
Change-Id: Ib6e3d6c81aad4c8aaac12accdb3936e4136235fc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 3fd4e9c619..c629651040 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -41,6 +41,7 @@ private slots: void attachedSelf(); void attachedType(); void badSequence(); + void basicBlocksWithBackJump(); void bindToValueType(); void bindingExpression(); void blockComments(); @@ -700,6 +701,40 @@ void tst_QmlCppCodegen::badSequence() QCOMPARE(dadsCousins.at(&dadsCousins, 0), other); } +static bool expectingMessage = false; +static void handler(QtMsgType type, const QMessageLogContext &, const QString &message) +{ + QVERIFY(expectingMessage); + QCOMPARE(type, QtDebugMsg); + QCOMPARE(message, u"false"); + expectingMessage = false; +} + +void tst_QmlCppCodegen::basicBlocksWithBackJump() +{ + QQmlEngine engine; + QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/basicBlocksWithBackJump.qml"_s)); + QVERIFY2(component.isReady(), qPrintable(component.errorString())); + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); + + const auto oldHandler = qInstallMessageHandler(&handler); + const auto guard = qScopeGuard([oldHandler]() { qInstallMessageHandler(oldHandler); }); + + // t1 does not log anything + QMetaObject::invokeMethod(o.data(), "t1"); + + // t2 logs "false" exactly once + expectingMessage = true; + QMetaObject::invokeMethod(o.data(), "t2"); + QVERIFY(!expectingMessage); + + // t3 logs "false" exactly once + expectingMessage = true; + QMetaObject::invokeMethod(o.data(), "t3"); + QVERIFY(!expectingMessage); +} + void tst_QmlCppCodegen::bindToValueType() { QQmlEngine engine; |
