diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-20 11:19:58 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-28 12:06:34 +0200 |
commit | 6ec334034adb726efb9e20bba81f5d5b2576940e (patch) | |
tree | b90803f49ddbbfe9e7f503f217cd7f0244069b7f /tests | |
parent | b30aaf3e333b8cc31ac42f5a650ac7f486d6940b (diff) |
QmlCompiler: Properly annotate ThrowException instruction
It doesn't write the accumulator, but it does read it. Generating code
for throwing exceptions reveals that we have to default-construct the
return type rather than converting from undefined/void when throwing an
exception.
Fixes: QTBUG-104447
Change-Id: I0a725679d8ecb7e87bb20528033097bc0c3c7bb6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 87f984714408bb5112fb38a66f0280b722ac9491)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/throwObjectName.qml | 6 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 13 |
3 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt index c11c537715..0acfb97338 100644 --- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt +++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt @@ -130,6 +130,7 @@ set(qml_files text.qml themerbad.qml themergood.qml + throwObjectName.qml undefinedResets.qml unknownAttached.qml unknownParameter.qml diff --git a/tests/auto/qml/qmlcppcodegen/data/throwObjectName.qml b/tests/auto/qml/qmlcppcodegen/data/throwObjectName.qml new file mode 100644 index 0000000000..98282998e9 --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/throwObjectName.qml @@ -0,0 +1,6 @@ +pragma Strict +import QtQml + +QtObject { + objectName: { throw "ouch" } +} diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 3d5d5ae37d..88ab3c5743 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -131,6 +131,7 @@ private slots: void invisibleTypes(); void functionTakingVar(); void javaScriptArgument(); + void throwObjectName(); }; void tst_QmlCppCodegen::simpleBinding() @@ -2018,6 +2019,18 @@ void tst_QmlCppCodegen::javaScriptArgument() QCOMPARE(o->property("d").toString(), u"9"_qs); } +void tst_QmlCppCodegen::throwObjectName() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/throwObjectName.qml"_qs)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + + QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/throwObjectName.qml:5:5: ouch"); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + QVERIFY(o->objectName().isEmpty()); +} + void tst_QmlCppCodegen::runInterpreted() { #ifdef Q_OS_ANDROID |