aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-06-20 11:19:58 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-06-23 09:35:56 +0200
commit87f984714408bb5112fb38a66f0280b722ac9491 (patch)
tree1173fe03e10f131e1a1e533e298f47539791a9cb /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parent6173fc0e4be93604286b9a424f1aa3ff5896082a (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. Pick-to: 6.2 6.3 6.4 Fixes: QTBUG-104447 Change-Id: I0a725679d8ecb7e87bb20528033097bc0c3c7bb6 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.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 45dfcfd02e..b41197b95f 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -121,6 +121,7 @@ private slots:
void invisibleListElementType();
void typePropertyClash();
void objectToString();
+ void throwObjectName();
};
void tst_QmlCppCodegen::simpleBinding()
@@ -2213,6 +2214,18 @@ void tst_QmlCppCodegen::objectToString()
QCOMPARE(o->property("no").toString(), u" no"_s); // throws, but that is ignored
}
+void tst_QmlCppCodegen::throwObjectName()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/throwObjectName.qml"_s));
+ 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