diff options
Diffstat (limited to 'tests/auto/tools')
-rw-r--r-- | tests/auto/tools/moc/allmocs_baseline_in.json | 83 | ||||
-rw-r--r-- | tests/auto/tools/moc/cxx11-trailing-return.h | 68 | ||||
-rw-r--r-- | tests/auto/tools/moc/enum_with_include.h | 5 | ||||
-rw-r--r-- | tests/auto/tools/moc/moc.pro | 1 | ||||
-rw-r--r-- | tests/auto/tools/moc/task189996.h | 8 | ||||
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 50 | ||||
-rw-r--r-- | tests/auto/tools/uic/baseline/config.ui.py | 6 |
7 files changed, 192 insertions, 29 deletions
diff --git a/tests/auto/tools/moc/allmocs_baseline_in.json b/tests/auto/tools/moc/allmocs_baseline_in.json index 6d17bebb5f..18282505e4 100644 --- a/tests/auto/tools/moc/allmocs_baseline_in.json +++ b/tests/auto/tools/moc/allmocs_baseline_in.json @@ -689,16 +689,6 @@ "access": "public", "name": "c", "returnType": "void" - }, - { - "access": "public", - "name": "d", - "returnType": "void" - }, - { - "access": "public", - "name": "e", - "returnType": "void" } ], "superClasses": [ @@ -1536,6 +1526,79 @@ { "classes": [ { + "className": "CXX11TrailingReturn", + "object": true, + "qualifiedClassName": "CXX11TrailingReturn", + "signals": [ + { + "access": "public", + "arguments": [ + { + "name": "i", + "type": "int" + } + ], + "name": "trailingSignalReturn", + "returnType": "void" + } + ], + "slots": [ + { + "access": "public", + "name": "fun", + "returnType": "void" + }, + { + "access": "public", + "arguments": [ + { + "name": "i", + "type": "int" + }, + { + "name": "b", + "type": "char" + } + ], + "name": "arguments", + "returnType": "int" + }, + { + "access": "public", + "arguments": [ + { + "name": "i", + "type": "int" + } + ], + "name": "inlineFunc", + "returnType": "int" + }, + { + "access": "public", + "name": "constRefReturn", + "returnType": "void" + }, + { + "access": "public", + "name": "constConstRefReturn", + "returnType": "void" + } + ], + "superClasses": [ + { + "access": "public", + "name": "QObject" + } + ] + } + ], + "inputFile": "cxx11-trailing-return.h", + "outputRevision": 67 + }, + { + "classes": [ + { "className": "ForwardDeclaredParamClass", "object": true, "qualifiedClassName": "ForwardDeclaredParamClass", diff --git a/tests/auto/tools/moc/cxx11-trailing-return.h b/tests/auto/tools/moc/cxx11-trailing-return.h new file mode 100644 index 0000000000..50f341e1c3 --- /dev/null +++ b/tests/auto/tools/moc/cxx11-trailing-return.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CXX11_TRAILING_RETURN_H +#define CXX11_TRAILING_RETURN_H +#include <QtCore/QObject> + +class CXX11TrailingReturn : public QObject +{ + Q_OBJECT +public slots: + inline auto fun() -> void; + inline auto arguments(int i, char b) -> int; + inline auto inlineFunc(int i) -> int + { + return i + 1; + } + + inline auto constRefReturn() -> const CXX11TrailingReturn & + { + return *this; + } + + inline auto constConstRefReturn() const -> const CXX11TrailingReturn & + { + return *this; + } + +signals: + auto trailingSignalReturn(int i) -> void; +}; + +auto CXX11TrailingReturn::fun() -> void +{ + return; +} + +auto CXX11TrailingReturn::arguments(int i, char b) -> int +{ + return i + int(b); +} + +#endif // CXX11_TRAILING_RETURN_H diff --git a/tests/auto/tools/moc/enum_with_include.h b/tests/auto/tools/moc/enum_with_include.h index b8abf77f12..cd53ba6a28 100644 --- a/tests/auto/tools/moc/enum_with_include.h +++ b/tests/auto/tools/moc/enum_with_include.h @@ -34,6 +34,11 @@ class Foo : public QObject { enum en { #include <enum_inc.h> }; + + enum class en2 { + #include <enum_inc.h> + reference = 42 + }; Q_OBJECT }; #endif diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro index cafc7bc184..c324b3a8cd 100644 --- a/tests/auto/tools/moc/moc.pro +++ b/tests/auto/tools/moc/moc.pro @@ -19,6 +19,7 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n task234909.h task240368.h pure-virtual-signals.h cxx11-enums.h \ cxx11-final-classes.h \ cxx11-explicit-override-control.h \ + cxx11-trailing-return.h \ forward-declared-param.h \ parse-defines.h \ function-with-attributes.h \ diff --git a/tests/auto/tools/moc/task189996.h b/tests/auto/tools/moc/task189996.h index f94a051b3a..ba9450c271 100644 --- a/tests/auto/tools/moc/task189996.h +++ b/tests/auto/tools/moc/task189996.h @@ -37,11 +37,9 @@ class InlineSlotsWithThrowDeclaration : public QObject Q_OBJECT public slots: - void a() throw() { } - void b() const throw() { } - void c() throw(); - void d() throw(int) { } - void e() const throw(int,double) { } + void a() noexcept { } + void b() const noexcept { } + void c() noexcept; }; #endif diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 0f801fe902..cc465a213a 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -41,7 +41,6 @@ #include "single_function_keyword.h" #include "backslash-newlines.h" #include "slots-with-void-template.h" -#include "pure-virtual-signals.h" #include "qinvokable.h" // msvc and friends crap out on it #if !defined(Q_CC_GNU) || defined(Q_OS_WIN) @@ -62,6 +61,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" @@ -630,7 +630,6 @@ public: private slots: void initTestCase(); - void slotWithException() throw(MyStruct); void dontStripNamespaces(); void oldStyleCasts(); void warnOnExtraSignalSlotQualifiaction(); @@ -687,6 +686,7 @@ private slots: void privateClass(); void cxx11Enums_data(); void cxx11Enums(); + void cxx11TrailingReturn(); void returnRefs(); void memberProperties_data(); void memberProperties(); @@ -782,12 +782,6 @@ void tst_Moc::initTestCase() #endif } -void tst_Moc::slotWithException() throw(MyStruct) -{ - // be happy - QVERIFY(true); -} - void tst_Moc::dontStripNamespaces() { Sender sender; @@ -1593,7 +1587,7 @@ void tst_Moc::qprivateproperties() #include "task189996.h" -void InlineSlotsWithThrowDeclaration::c() throw() {} +void InlineSlotsWithThrowDeclaration::c() noexcept {} void tst_Moc::inlineSlotsWithThrowDeclaration() { @@ -1602,8 +1596,6 @@ void tst_Moc::inlineSlotsWithThrowDeclaration() QVERIFY(mobj->indexOfSlot("a()") != -1); QVERIFY(mobj->indexOfSlot("b()") != -1); QVERIFY(mobj->indexOfSlot("c()") != -1); - QVERIFY(mobj->indexOfSlot("d()") != -1); - QVERIFY(mobj->indexOfSlot("e()") != -1); } void tst_Moc::warnOnPropertyWithoutREAD() @@ -2200,6 +2192,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 +2345,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; diff --git a/tests/auto/tools/uic/baseline/config.ui.py b/tests/auto/tools/uic/baseline/config.ui.py index 8cf1600b41..d8f1dec3a4 100644 --- a/tests/auto/tools/uic/baseline/config.ui.py +++ b/tests/auto/tools/uic/baseline/config.ui.py @@ -36,9 +36,9 @@ ## WARNING! All changes made in this file will be lost when recompiling UI file! ################################################################################ -from PySide2.QtCore import * -from PySide2.QtGui import * -from PySide2.QtWidgets import * +from PySide2.QtCore import * # type: ignore +from PySide2.QtGui import * # type: ignore +from PySide2.QtWidgets import * # type: ignore from gammaview import GammaView |