diff options
Diffstat (limited to 'tests/auto/tools/moc/tst_moc.cpp')
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 0f801fe902..c716aead21 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -62,6 +62,7 @@ #include "cxx11-enums.h" #include "cxx11-final-classes.h" #include "cxx11-explicit-override-control.h" +#include "cxx11-trailing-return.h" #include "parse-defines.h" #include "related-metaobjects-in-namespaces.h" @@ -687,6 +688,7 @@ private slots: void privateClass(); void cxx11Enums_data(); void cxx11Enums(); + void cxx11TrailingReturn(); void returnRefs(); void memberProperties_data(); void memberProperties(); @@ -2200,6 +2202,30 @@ void tst_Moc::warnings_data() << QString() << QString("standard input:2: Error: Plugin Metadata file \"does.not.exists\" does not exist. Declaration will be ignored"); + QTest::newRow("Auto-declared, missing trailing return") + << QByteArray("class X { \n public slots: \n auto fun() { return 1; } };") + << QStringList() + << 1 + << QString() + << QString("standard input:3: Error: Function declared with auto as return type but missing trailing return type. Return type deduction is not supported."); + + QTest::newRow("Auto-declared, volatile auto as trailing return type") + << QByteArray("class X { \n public slots: \n auto fun() -> volatile auto { return 1; } };") + << QStringList() + << 1 + << QString() + << QString("standard input:3: Error: Function declared with auto as return type but missing trailing return type. Return type deduction is not supported."); + + // We don't currently support the decltype keyword, so it's not the same error as above. + // The test is just here to make sure this keeps generating an error until return type deduction + // is supported. + QTest::newRow("Auto-declared, decltype in trailing return type") + << QByteArray("class X { \n public slots: \n auto fun() -> decltype(0+1) { return 1; } };") + << QStringList() + << 1 + << QString() + << QString("standard input:3: Parse error at \"decltype\""); + #ifdef Q_OS_LINUX // Limit to Linux because the error message is platform-dependent QTest::newRow("Q_PLUGIN_METADATA: unreadable file") << QByteArray("class X { \n Q_PLUGIN_METADATA(FILE \".\") \n };") @@ -2329,6 +2355,18 @@ void tst_Moc::cxx11Enums() QCOMPARE(meta->enumerator(idx).isScoped(), isScoped); } +void tst_Moc::cxx11TrailingReturn() +{ + CXX11TrailingReturn retClass; + const QMetaObject *mobj = retClass.metaObject(); + QVERIFY(mobj->indexOfSlot("fun()") != -1); + QVERIFY(mobj->indexOfSlot("arguments(int,char)") != -1); + QVERIFY(mobj->indexOfSlot("inlineFunc(int)") != -1); + QVERIFY(mobj->indexOfSlot("constRefReturn()") != -1); + QVERIFY(mobj->indexOfSlot("constConstRefReturn()") != -1); + QVERIFY(mobj->indexOfSignal("trailingSignalReturn(int)") != -1); +} + void tst_Moc::returnRefs() { TestClass tst; |