diff options
Diffstat (limited to 'tests/auto/tools/moc')
70 files changed, 674 insertions, 163 deletions
diff --git a/tests/auto/tools/moc/CMakeLists.txt b/tests/auto/tools/moc/CMakeLists.txt index b01b92b634..1377c48306 100644 --- a/tests/auto/tools/moc/CMakeLists.txt +++ b/tests/auto/tools/moc/CMakeLists.txt @@ -1,13 +1,15 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -# special case skip regeneration -# Generated from moc.pro. - ##################################################################### ## tst_moc Test: ##################################################################### +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_moc LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() set(JSON_HEADERS backslash-newlines.h @@ -28,6 +30,7 @@ set(JSON_HEADERS moc_include.h namespace.h namespaced-flags.h + namespaced-base-class.h no-keywords.h non-gadget-parent-class.h oldstyle-casts.h @@ -41,6 +44,7 @@ set(JSON_HEADERS related-metaobjects-in-gadget.h related-metaobjects-in-namespaces.h related-metaobjects-name-conflict.h + signal-with-default-arg.h single-quote-digit-separator-n3781.h single_function_keyword.h slots-with-void-template.h diff --git a/tests/auto/tools/moc/Test.framework/Headers/testinterface.h b/tests/auto/tools/moc/Test.framework/Headers/testinterface.h index b721e7207b..486648e312 100644 --- a/tests/auto/tools/moc/Test.framework/Headers/testinterface.h +++ b/tests/auto/tools/moc/Test.framework/Headers/testinterface.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TESTINTERFACE_H #define TESTINTERFACE_H diff --git a/tests/auto/tools/moc/allmocs_baseline_in.json b/tests/auto/tools/moc/allmocs_baseline_in.json index e1c6a5d7d8..5cbcb99e68 100644 --- a/tests/auto/tools/moc/allmocs_baseline_in.json +++ b/tests/auto/tools/moc/allmocs_baseline_in.json @@ -91,6 +91,7 @@ "isClass": false, "isFlag": false, "name": "TypedEnum", + "type": "char", "values": [ "B0", "B1", @@ -102,6 +103,7 @@ "isClass": true, "isFlag": false, "name": "TypedEnumClass", + "type": "char", "values": [ "C0", "C1", @@ -147,6 +149,7 @@ "isClass": true, "isFlag": false, "name": "TypedEnumStruct", + "type": "char", "values": [ "H0", "H1", @@ -188,6 +191,7 @@ "isClass": false, "isFlag": false, "name": "TypedEnum", + "type": "char", "values": [ "B0", "B1", @@ -199,6 +203,7 @@ "isClass": true, "isFlag": false, "name": "TypedEnumClass", + "type": "char", "values": [ "C0", "C1", @@ -232,6 +237,65 @@ ], "gadget": true, "qualifiedClassName": "CXX11Enums2" + }, + { + "className": "CXX11Enums3", + "enums": [ + { + "isClass": true, + "isFlag": false, + "name": "EnumClass", + "values": [ + "A0", + "A1", + "A2", + "A3" + ] + }, + { + "isClass": false, + "isFlag": false, + "name": "TypedEnum", + "type": "char", + "values": [ + "B0", + "B1", + "B2", + "B3" + ] + }, + { + "isClass": true, + "isFlag": false, + "name": "TypedEnumClass", + "type": "char", + "values": [ + "C0", + "C1", + "C2", + "C3" + ] + }, + { + "isClass": false, + "isFlag": false, + "name": "NormalEnum", + "values": [ + "D2", + "D3", + "D0", + "D1" + ] + } + ], + "object": true, + "qualifiedClassName": "CXX11Enums3", + "superClasses": [ + { + "access": "public", + "name": "QObject" + } + ] } ], "inputFile": "cxx11-enums.h", @@ -1258,6 +1322,35 @@ { "classes": [ { + "className": "Base", + "object": true, + "qualifiedClassName": "QTBUG_101141::Base", + "superClasses": [ + { + "access": "public", + "name": "QObject" + } + ] + }, + { + "className": "Derived", + "object": true, + "qualifiedClassName": "QTBUG_101141::Derived", + "superClasses": [ + { + "access": "public", + "fullyQualifiedName": "QTBUG_101141::Base", + "name": "Base" + } + ] + } + ], + "inputFile": "namespaced-base-class.h", + "outputRevision": 68 + }, + { + "classes": [ + { "className": "Bar", "enums": [ { @@ -2450,6 +2543,42 @@ { "classes": [ { + "className": "SignalWithDefaultArg", + "object": true, + "qualifiedClassName": "SignalWithDefaultArg", + "signals": [ + { + "access": "public", + "arguments": [ + { + "name": "i", + "type": "int" + } + ], + "name": "signalWithDefaultArg", + "returnType": "void" + }, + { + "access": "public", + "isCloned": true, + "name": "signalWithDefaultArg", + "returnType": "void" + } + ], + "superClasses": [ + { + "access": "public", + "name": "QObject" + } + ] + } + ], + "inputFile": "signal-with-default-arg.h", + "outputRevision": 68 + }, + { + "classes": [ + { "className": "KDAB", "enums": [ { diff --git a/tests/auto/tools/moc/assign-namespace.h b/tests/auto/tools/moc/assign-namespace.h index 63f354a22a..6e375d676c 100644 --- a/tests/auto/tools/moc/assign-namespace.h +++ b/tests/auto/tools/moc/assign-namespace.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef ASSIGN_NAMESPACE_H #define ASSIGN_NAMESPACE_H diff --git a/tests/auto/tools/moc/backslash-newlines.h b/tests/auto/tools/moc/backslash-newlines.h index 899cb5d2fa..d4c1492a21 100644 --- a/tests/auto/tools/moc/backslash-newlines.h +++ b/tests/auto/tools/moc/backslash-newlines.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef BACKSLASH_NEWLINES_H #define BACKSLASH_NEWLINES_H @@ -30,6 +30,7 @@ public slots: QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wcomment") +QT_WARNING_DISABLE_GCC("-Wcomment") // ends with \\\r should not make moc crash (QTBUG-53441) (no new lines on purpose!!) \ diff --git a/tests/auto/tools/moc/c-comments.h b/tests/auto/tools/moc/c-comments.h index 36b7b9625a..b83549715d 100644 --- a/tests/auto/tools/moc/c-comments.h +++ b/tests/auto/tools/moc/c-comments.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef C_COMMENTS_H #define C_COMMENTS_H diff --git a/tests/auto/tools/moc/cstyle-enums.h b/tests/auto/tools/moc/cstyle-enums.h index 36d6243d55..a173913e06 100644 --- a/tests/auto/tools/moc/cstyle-enums.h +++ b/tests/auto/tools/moc/cstyle-enums.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef CSTYLE_ENUMS_H #define CSTYLE_ENUMS_H diff --git a/tests/auto/tools/moc/cxx-attributes.h b/tests/auto/tools/moc/cxx-attributes.h index 6301d7804c..54649b93fa 100644 --- a/tests/auto/tools/moc/cxx-attributes.h +++ b/tests/auto/tools/moc/cxx-attributes.h @@ -1,5 +1,5 @@ // Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef CXXATTRIBUTE_H #define CXXATTRIBUTE_H diff --git a/tests/auto/tools/moc/cxx11-enums.h b/tests/auto/tools/moc/cxx11-enums.h index cd82a5df6d..7547ed81c1 100644 --- a/tests/auto/tools/moc/cxx11-enums.h +++ b/tests/auto/tools/moc/cxx11-enums.h @@ -1,5 +1,5 @@ // Copyright (C) 2011 Olivier Goffart. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef CXX11_ENUMS_H #define CXX11_ENUMS_H @@ -47,4 +47,20 @@ public: Q_FLAGS(ClassFlags) }; +class CXX11Enums3 : public QObject +{ + Q_OBJECT +public: + enum class EnumClass { A0, A1, A2, A3 }; + enum TypedEnum : char { B0, B1 , B2, B3 }; + enum class TypedEnumClass : char { C0, C1, C2, C3 }; + enum NormalEnum { D2 = 2, D3, D0 =0 , D1 }; + enum class ClassFlag { F0 = 1, F1 = 2, F2 = 4, F3 = 8 }; + + Q_ENUM(EnumClass) + Q_ENUM(TypedEnum) + Q_ENUM(TypedEnumClass) + Q_ENUM(NormalEnum) +}; + #endif // CXX11_ENUMS_H diff --git a/tests/auto/tools/moc/cxx11-explicit-override-control.h b/tests/auto/tools/moc/cxx11-explicit-override-control.h index 884f50dff3..c741558419 100644 --- a/tests/auto/tools/moc/cxx11-explicit-override-control.h +++ b/tests/auto/tools/moc/cxx11-explicit-override-control.h @@ -1,5 +1,5 @@ // Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TESTS_AUTO_CORELIB_TOOLS_MOC_CXX11_EXPLICIT_OVERRIDE_CONTROL_H #define TESTS_AUTO_CORELIB_TOOLS_MOC_CXX11_EXPLICIT_OVERRIDE_CONTROL_H diff --git a/tests/auto/tools/moc/cxx11-final-classes.h b/tests/auto/tools/moc/cxx11-final-classes.h index 8471761ef2..9d1a21bf96 100644 --- a/tests/auto/tools/moc/cxx11-final-classes.h +++ b/tests/auto/tools/moc/cxx11-final-classes.h @@ -1,5 +1,5 @@ // Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TESTS_AUTO_CORELIB_TOOLS_MOC_CXX11_FINAL_CLASSES_H #define TESTS_AUTO_CORELIB_TOOLS_MOC_CXX11_FINAL_CLASSES_H diff --git a/tests/auto/tools/moc/cxx11-trailing-return.h b/tests/auto/tools/moc/cxx11-trailing-return.h index 0f0441e5bf..f8ee031dae 100644 --- a/tests/auto/tools/moc/cxx11-trailing-return.h +++ b/tests/auto/tools/moc/cxx11-trailing-return.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef CXX11_TRAILING_RETURN_H #define CXX11_TRAILING_RETURN_H diff --git a/tests/auto/tools/moc/cxx17-namespaces.h b/tests/auto/tools/moc/cxx17-namespaces.h index 2bc3e6595a..9c346c7993 100644 --- a/tests/auto/tools/moc/cxx17-namespaces.h +++ b/tests/auto/tools/moc/cxx17-namespaces.h @@ -1,5 +1,5 @@ // Copyright (C) 2011 Olivier Goffart. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef CXX17_NAMESPACES_H #define CXX17_NAMESPACES_H diff --git a/tests/auto/tools/moc/dir-in-include-path.h b/tests/auto/tools/moc/dir-in-include-path.h index 29e1ad1689..94f420ea6c 100644 --- a/tests/auto/tools/moc/dir-in-include-path.h +++ b/tests/auto/tools/moc/dir-in-include-path.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef DIR_IN_INCLUDE_PATH_H #define DIR_IN_INCLUDE_PATH_H diff --git a/tests/auto/tools/moc/dollars.h b/tests/auto/tools/moc/dollars.h index 4c0f59bf03..36cc864fc6 100644 --- a/tests/auto/tools/moc/dollars.h +++ b/tests/auto/tools/moc/dollars.h @@ -1,5 +1,5 @@ // Copyright (C) 2013 Olivier Goffart <ogoffart@woboq.com> -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef DOLLARS_H #define DOLLARS_H diff --git a/tests/auto/tools/moc/enum_with_include.h b/tests/auto/tools/moc/enum_with_include.h index 9845cb03d5..7cf6bf512c 100644 --- a/tests/auto/tools/moc/enum_with_include.h +++ b/tests/auto/tools/moc/enum_with_include.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef ENUM_WITH_INCLUDE_H #define ENUM_WITH_INCLUDE_H diff --git a/tests/auto/tools/moc/error-on-wrong-notify.h b/tests/auto/tools/moc/error-on-wrong-notify.h index 66a36c3809..90d1eded31 100644 --- a/tests/auto/tools/moc/error-on-wrong-notify.h +++ b/tests/auto/tools/moc/error-on-wrong-notify.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef ERROR_ON_WRONG_NOTIFY_H #define ERROR_ON_WRONG_NOTIFY_H diff --git a/tests/auto/tools/moc/escapes-in-string-literals.h b/tests/auto/tools/moc/escapes-in-string-literals.h index c7fbc10b70..5514bc1000 100644 --- a/tests/auto/tools/moc/escapes-in-string-literals.h +++ b/tests/auto/tools/moc/escapes-in-string-literals.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef ESCAPES_IN_STRING_LITERALS_H #define ESCAPES_IN_STRING_LITERALS_H diff --git a/tests/auto/tools/moc/extraqualification.h b/tests/auto/tools/moc/extraqualification.h index d2391c97e8..33cc48158f 100644 --- a/tests/auto/tools/moc/extraqualification.h +++ b/tests/auto/tools/moc/extraqualification.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef EXTRAQUALIFICATION_H #define EXTRAQUALIFICATION_H diff --git a/tests/auto/tools/moc/forgotten-qinterface.h b/tests/auto/tools/moc/forgotten-qinterface.h index 7da5080e6f..663ab162f8 100644 --- a/tests/auto/tools/moc/forgotten-qinterface.h +++ b/tests/auto/tools/moc/forgotten-qinterface.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef FORGOTTEN_QINTERFACE_H #define FORGOTTEN_QINTERFACE_H diff --git a/tests/auto/tools/moc/forward-declared-param.h b/tests/auto/tools/moc/forward-declared-param.h index 72bf929616..e494b18ba5 100644 --- a/tests/auto/tools/moc/forward-declared-param.h +++ b/tests/auto/tools/moc/forward-declared-param.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 Intel Corporation. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef FORWARD_DECLARED_PARAM_H #define FORWARD_DECLARED_PARAM_H diff --git a/tests/auto/tools/moc/function-with-attributes.h b/tests/auto/tools/moc/function-with-attributes.h index d55a879906..be7c8d9aaa 100644 --- a/tests/auto/tools/moc/function-with-attributes.h +++ b/tests/auto/tools/moc/function-with-attributes.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef FUNCTION_WITH_ATTRIBUTES_H #define FUNCTION_WITH_ATTRIBUTES_H diff --git a/tests/auto/tools/moc/fwdclass1.h b/tests/auto/tools/moc/fwdclass1.h index 93944fbdc9..eaaa7c380f 100644 --- a/tests/auto/tools/moc/fwdclass1.h +++ b/tests/auto/tools/moc/fwdclass1.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com> -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifdef FWDCLASS1_H #error "This file can only be included once" diff --git a/tests/auto/tools/moc/fwdclass2.h b/tests/auto/tools/moc/fwdclass2.h index 7f988aae43..588f5b4de3 100644 --- a/tests/auto/tools/moc/fwdclass2.h +++ b/tests/auto/tools/moc/fwdclass2.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com> -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifdef FWDCLASS2_H #error "This file can only be included once" diff --git a/tests/auto/tools/moc/fwdclass3.h b/tests/auto/tools/moc/fwdclass3.h index 459c75ca21..5ecdb2ce6e 100644 --- a/tests/auto/tools/moc/fwdclass3.h +++ b/tests/auto/tools/moc/fwdclass3.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com> -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifdef FWDCLASS3_H #error "This file can only be included once" diff --git a/tests/auto/tools/moc/gadgetwithnoenums.h b/tests/auto/tools/moc/gadgetwithnoenums.h index 62106cbf73..5ef8bced8c 100644 --- a/tests/auto/tools/moc/gadgetwithnoenums.h +++ b/tests/auto/tools/moc/gadgetwithnoenums.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TASK175491 #define TASK175491 diff --git a/tests/auto/tools/moc/grand-parent-gadget-class.h b/tests/auto/tools/moc/grand-parent-gadget-class.h index f09b51f33c..d5adfb9974 100644 --- a/tests/auto/tools/moc/grand-parent-gadget-class.h +++ b/tests/auto/tools/moc/grand-parent-gadget-class.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef GRANDPARENTGADGETCLASS_H #define GRANDPARENTGADGETCLASS_H diff --git a/tests/auto/tools/moc/interface-from-framework.h b/tests/auto/tools/moc/interface-from-framework.h index 0285c82bb6..f8f80cbafb 100644 --- a/tests/auto/tools/moc/interface-from-framework.h +++ b/tests/auto/tools/moc/interface-from-framework.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef INTERFACE_FROM_FRAMEWORK_H #define INTERFACE_FROM_FRAMEWORK_H diff --git a/tests/auto/tools/moc/interface-from-include.h b/tests/auto/tools/moc/interface-from-include.h index af3dcf3371..6e92d30142 100644 --- a/tests/auto/tools/moc/interface-from-include.h +++ b/tests/auto/tools/moc/interface-from-include.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef INTERFACE_FROM_INCLUDE_H #define INTERFACE_FROM_INCLUDE_H diff --git a/tests/auto/tools/moc/macro-on-cmdline.h b/tests/auto/tools/moc/macro-on-cmdline.h index fce8413752..d7530cdcb1 100644 --- a/tests/auto/tools/moc/macro-on-cmdline.h +++ b/tests/auto/tools/moc/macro-on-cmdline.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef MACRO_ON_CMDLINE_H #define MACRO_ON_CMDLINE_H diff --git a/tests/auto/tools/moc/moc_include.h b/tests/auto/tools/moc/moc_include.h index 51d48c9fa3..398459766e 100644 --- a/tests/auto/tools/moc/moc_include.h +++ b/tests/auto/tools/moc/moc_include.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com> -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef MOC_INCLUDE_H #define MOC_INCLUDE_H diff --git a/tests/auto/tools/moc/namespace.h b/tests/auto/tools/moc/namespace.h index aa7ddd937f..22fe0b91f5 100644 --- a/tests/auto/tools/moc/namespace.h +++ b/tests/auto/tools/moc/namespace.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef NAMESPACE_H #define NAMESPACE_H diff --git a/tests/auto/tools/moc/namespace_no_merge.h b/tests/auto/tools/moc/namespace_no_merge.h index fc7123172f..e2f277fde5 100644 --- a/tests/auto/tools/moc/namespace_no_merge.h +++ b/tests/auto/tools/moc/namespace_no_merge.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef NAMESPACE_NO_MERGE_H #define NAMESPACE_NO_MERGE_H diff --git a/tests/auto/tools/moc/namespaced-base-class.h b/tests/auto/tools/moc/namespaced-base-class.h new file mode 100644 index 0000000000..46bd2bae29 --- /dev/null +++ b/tests/auto/tools/moc/namespaced-base-class.h @@ -0,0 +1,20 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef TST_MOC_NAMESPACED_BASE_CLASS_H +#define TST_MOC_NAMESPACED_BASE_CLASS_H + +#include <QObject> + +namespace QTBUG_101141 { + class Base : public QObject { + Q_OBJECT + }; + + class Derived : public Base + { + Q_OBJECT + }; +} + +#endif // TST_MOC_NAMESPACED_BASE_CLASS_H diff --git a/tests/auto/tools/moc/namespaced-flags.h b/tests/auto/tools/moc/namespaced-flags.h index c3c3ea83dc..39ff5c1f9a 100644 --- a/tests/auto/tools/moc/namespaced-flags.h +++ b/tests/auto/tools/moc/namespaced-flags.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef NAMESPACED_FLAGS_H #define NAMESPACED_FLAGS_H diff --git a/tests/auto/tools/moc/no-keywords.h b/tests/auto/tools/moc/no-keywords.h index 87270dbf7a..bf9beb4663 100644 --- a/tests/auto/tools/moc/no-keywords.h +++ b/tests/auto/tools/moc/no-keywords.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef NO_KEYWORDS_H #define NO_KEYWORDS_H diff --git a/tests/auto/tools/moc/non-gadget-parent-class.h b/tests/auto/tools/moc/non-gadget-parent-class.h index 2155ce7cd1..c64075b572 100644 --- a/tests/auto/tools/moc/non-gadget-parent-class.h +++ b/tests/auto/tools/moc/non-gadget-parent-class.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef NONGADGETPARENTCLASS_H #define NONGADGETPARENTCLASS_H diff --git a/tests/auto/tools/moc/oldstyle-casts.h b/tests/auto/tools/moc/oldstyle-casts.h index 1bd619d147..017f195b7b 100644 --- a/tests/auto/tools/moc/oldstyle-casts.h +++ b/tests/auto/tools/moc/oldstyle-casts.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef OLDSTYLE_CASTS_H #define OLDSTYLE_CASTS_H diff --git a/tests/auto/tools/moc/os9-newlines.h b/tests/auto/tools/moc/os9-newlines.h index 82bddd117d..2da70f6a89 100644 --- a/tests/auto/tools/moc/os9-newlines.h +++ b/tests/auto/tools/moc/os9-newlines.h @@ -1 +1 @@ -// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QObject>
class Os9Newlines : public QObject
{
Q_OBJECT
public Q_SLOTS:
inline void testSlot() {}
};
\ No newline at end of file +// REUSE-IgnoreStart
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
// REUSE-IgnoreEnd
#include <QObject>
class Os9Newlines : public QObject
{
Q_OBJECT
public Q_SLOTS:
inline void testSlot() {}
};
\ No newline at end of file diff --git a/tests/auto/tools/moc/parse-boost.h b/tests/auto/tools/moc/parse-boost.h index e2d3168c0c..8f327a131d 100644 --- a/tests/auto/tools/moc/parse-boost.h +++ b/tests/auto/tools/moc/parse-boost.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef PARSE_BOOST_H #define PARSE_BOOST_H diff --git a/tests/auto/tools/moc/parse-defines.h b/tests/auto/tools/moc/parse-defines.h index 330f90bc8b..238d33246f 100644 --- a/tests/auto/tools/moc/parse-defines.h +++ b/tests/auto/tools/moc/parse-defines.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef PARSE_DEFINES_H #define PARSE_DEFINES_H diff --git a/tests/auto/tools/moc/plugin_metadata.h b/tests/auto/tools/moc/plugin_metadata.h index b0ab8a0442..5f2a1885f6 100644 --- a/tests/auto/tools/moc/plugin_metadata.h +++ b/tests/auto/tools/moc/plugin_metadata.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TESTPLUGINMETADATA #define TESTPLUGINMETADATA diff --git a/tests/auto/tools/moc/pointery_to_incomplete.h b/tests/auto/tools/moc/pointery_to_incomplete.h index 46cd04d763..5d0ac859d6 100644 --- a/tests/auto/tools/moc/pointery_to_incomplete.h +++ b/tests/auto/tools/moc/pointery_to_incomplete.h @@ -1,5 +1,5 @@ // Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef POINTERY_TO_INCOMPLETE_H #define POINTERY_TO_INCOMPLETE_H diff --git a/tests/auto/tools/moc/pp-dollar-signs.h b/tests/auto/tools/moc/pp-dollar-signs.h index c12cce3bbf..6ba39cb903 100644 --- a/tests/auto/tools/moc/pp-dollar-signs.h +++ b/tests/auto/tools/moc/pp-dollar-signs.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef PP_DOLLAR_SIGNS_H #define PP_DOLLAR_SIGNS_H diff --git a/tests/auto/tools/moc/pure-virtual-signals.h b/tests/auto/tools/moc/pure-virtual-signals.h index 15113dbcdc..3c996a8628 100644 --- a/tests/auto/tools/moc/pure-virtual-signals.h +++ b/tests/auto/tools/moc/pure-virtual-signals.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef PURE_VIRTUAL_SIGNALS_H #define PURE_VIRTUAL_SIGNALS_H diff --git a/tests/auto/tools/moc/qinvokable.h b/tests/auto/tools/moc/qinvokable.h index 63d49462e1..e2181d909d 100644 --- a/tests/auto/tools/moc/qinvokable.h +++ b/tests/auto/tools/moc/qinvokable.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QINVOKABLE_H #define QINVOKABLE_H diff --git a/tests/auto/tools/moc/qmlmacro.h b/tests/auto/tools/moc/qmlmacro.h index cb3b291bf1..e44138a3b6 100644 --- a/tests/auto/tools/moc/qmlmacro.h +++ b/tests/auto/tools/moc/qmlmacro.h @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QMlMACRO_H diff --git a/tests/auto/tools/moc/qprivateslots.h b/tests/auto/tools/moc/qprivateslots.h index 670c93d7e4..d4b158bbc4 100644 --- a/tests/auto/tools/moc/qprivateslots.h +++ b/tests/auto/tools/moc/qprivateslots.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QPRIVATESLOTS_H #define QPRIVATESLOTS_H diff --git a/tests/auto/tools/moc/qtbug-35657-gadget.h b/tests/auto/tools/moc/qtbug-35657-gadget.h index 0c756aecd3..d97e1f7f45 100644 --- a/tests/auto/tools/moc/qtbug-35657-gadget.h +++ b/tests/auto/tools/moc/qtbug-35657-gadget.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QTBUG_35657_GADGET_H #define QTBUG_35657_GADGET_H diff --git a/tests/auto/tools/moc/related-metaobjects-in-gadget.h b/tests/auto/tools/moc/related-metaobjects-in-gadget.h index ed0ca7a5b1..0ea6c09a73 100644 --- a/tests/auto/tools/moc/related-metaobjects-in-gadget.h +++ b/tests/auto/tools/moc/related-metaobjects-in-gadget.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef RELATED_METAOBJECTS_IN_GADGET_H #define RELATED_METAOBJECTS_IN_GADGET_H diff --git a/tests/auto/tools/moc/related-metaobjects-in-namespaces.h b/tests/auto/tools/moc/related-metaobjects-in-namespaces.h index 241e2e32dc..efd8210767 100644 --- a/tests/auto/tools/moc/related-metaobjects-in-namespaces.h +++ b/tests/auto/tools/moc/related-metaobjects-in-namespaces.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef RELATED_METAOBJECTS_IN_NAMESPACES_H #define RELATED_METAOBJECTS_IN_NAMESPACES_H diff --git a/tests/auto/tools/moc/related-metaobjects-name-conflict.h b/tests/auto/tools/moc/related-metaobjects-name-conflict.h index 19f22988c5..cccd97e4e7 100644 --- a/tests/auto/tools/moc/related-metaobjects-name-conflict.h +++ b/tests/auto/tools/moc/related-metaobjects-name-conflict.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef RELATED_METAOBJECTS_NAME_CONFLICT_H #define RELATED_METAOBJECTS_NAME_CONFLICT_H diff --git a/tests/auto/tools/moc/signal-with-default-arg.h b/tests/auto/tools/moc/signal-with-default-arg.h new file mode 100644 index 0000000000..3fd98712eb --- /dev/null +++ b/tests/auto/tools/moc/signal-with-default-arg.h @@ -0,0 +1,16 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef SIGNAL_WITH_DEFAULT_ARG_H +#define SIGNAL_WITH_DEFAULT_ARG_H + +#include <QtCore/qobject.h> + +class SignalWithDefaultArg : public QObject +{ + Q_OBJECT +signals: + void signalWithDefaultArg(int i = 12); +}; + +#endif // SIGNAL_WITH_DEFAULT_ARG_H diff --git a/tests/auto/tools/moc/single-quote-digit-separator-n3781.h b/tests/auto/tools/moc/single-quote-digit-separator-n3781.h index 596416404d..f272ecbddf 100644 --- a/tests/auto/tools/moc/single-quote-digit-separator-n3781.h +++ b/tests/auto/tools/moc/single-quote-digit-separator-n3781.h @@ -1,5 +1,5 @@ // Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef SINGLE_QUOTE_DIGIT_SEPARATOR_N3781_H #define SINGLE_QUOTE_DIGIT_SEPARATOR_N3781_H diff --git a/tests/auto/tools/moc/single_function_keyword.h b/tests/auto/tools/moc/single_function_keyword.h index fc65561d72..0c907db9ef 100644 --- a/tests/auto/tools/moc/single_function_keyword.h +++ b/tests/auto/tools/moc/single_function_keyword.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef SINGLE_FUNCTION_KEYWORD_H #define SINGLE_FUNCTION_KEYWORD_H diff --git a/tests/auto/tools/moc/slots-with-void-template.h b/tests/auto/tools/moc/slots-with-void-template.h index 41a9f0ff47..5b51041155 100644 --- a/tests/auto/tools/moc/slots-with-void-template.h +++ b/tests/auto/tools/moc/slots-with-void-template.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef SLOTS_WITH_VOID_TEMPLATE_H #define SLOTS_WITH_VOID_TEMPLATE_H diff --git a/tests/auto/tools/moc/task192552.h b/tests/auto/tools/moc/task192552.h index 83afcb0184..aad545292f 100644 --- a/tests/auto/tools/moc/task192552.h +++ b/tests/auto/tools/moc/task192552.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TASK192552_H #define TASK192552_H diff --git a/tests/auto/tools/moc/task234909.h b/tests/auto/tools/moc/task234909.h index 42c718e87c..4be1383f4a 100644 --- a/tests/auto/tools/moc/task234909.h +++ b/tests/auto/tools/moc/task234909.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TASK234909_H #define TASK234909_H diff --git a/tests/auto/tools/moc/task240368.h b/tests/auto/tools/moc/task240368.h index 94305bede3..1e728d373f 100644 --- a/tests/auto/tools/moc/task240368.h +++ b/tests/auto/tools/moc/task240368.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only // moc parsing issue with "unsigned" subphrase #ifndef TASK240368_H diff --git a/tests/auto/tools/moc/task87883.h b/tests/auto/tools/moc/task87883.h index aba746ddc6..60ca529d53 100644 --- a/tests/auto/tools/moc/task87883.h +++ b/tests/auto/tools/moc/task87883.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TASK87883_H #define TASK87883_H diff --git a/tests/auto/tools/moc/tech-preview.h b/tests/auto/tools/moc/tech-preview.h new file mode 100644 index 0000000000..8f285048e4 --- /dev/null +++ b/tests/auto/tools/moc/tech-preview.h @@ -0,0 +1,43 @@ +// Copyright (C) 2024 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef TECH_PREVIEW_H +#define TECH_PREVIEW_H + +#include <QObject> + +class QT_TECH_PREVIEW_API MyTechPreviewObject : public QObject +{ + QT_TECH_PREVIEW_API + Q_OBJECT + + QT_TECH_PREVIEW_API + Q_PROPERTY(int status MEMBER m_status) + + int m_status = 0; + +public: + void myMethod() {} + QT_TECH_PREVIEW_API void myTPMethod() {} + + Q_INVOKABLE QT_TECH_PREVIEW_API void myTPInvokable1() {} + QT_TECH_PREVIEW_API Q_INVOKABLE void myTPInvokable2() {} + + enum class QT_TECH_PREVIEW_API MyTechPreviewEnum + { + A, B, C, + TP QT_TECH_PREVIEW_API, + X, Y, Z + }; + +signals: + void mySignal(); + QT_TECH_PREVIEW_API void myTPSignal(); + +public Q_SLOTS: + void mySlot() {} + QT_TECH_PREVIEW_API void myTPSlot() {} +}; + + +#endif // TECH_PREVIEW_H diff --git a/tests/auto/tools/moc/template-gtgt.h b/tests/auto/tools/moc/template-gtgt.h index 5572c4c1ae..ed2da17405 100644 --- a/tests/auto/tools/moc/template-gtgt.h +++ b/tests/auto/tools/moc/template-gtgt.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TEMPLATE_GTGT_H #define TEMPLATE_GTGT_H diff --git a/tests/auto/tools/moc/testproject/Plugin/Plugin.h b/tests/auto/tools/moc/testproject/Plugin/Plugin.h index ba79879337..a947bf968a 100644 --- a/tests/auto/tools/moc/testproject/Plugin/Plugin.h +++ b/tests/auto/tools/moc/testproject/Plugin/Plugin.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QObject> struct MyInterface diff --git a/tests/auto/tools/moc/trigraphs.h b/tests/auto/tools/moc/trigraphs.h index 106199d39e..6d0ce2cf69 100644 --- a/tests/auto/tools/moc/trigraphs.h +++ b/tests/auto/tools/moc/trigraphs.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TRIGRAPHS_H #define TRIGRAPHS_H diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 3580703aad..d24dfa11f7 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -1,15 +1,18 @@ // Copyright (C) 2020 The Qt Company Ltd. // Copyright (C) 2020 Olivier Goffart <ogoffart@woboq.com> -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> #include <QSignalSpy> #include <stdio.h> +#include <optional> #include <qobject.h> #include <qmetaobject.h> #include <qjsondocument.h> -#include <qversionnumber.h> #include <qregularexpression.h> +#include <qtyperevision.h> + +#include <private/qobject_p.h> #include "using-namespaces.h" #include "assign-namespace.h" @@ -56,8 +59,14 @@ #include "fwdclass2.h" #include "fwdclass3.h" +#include "signal-with-default-arg.h" + #include "qmlmacro.h" +#include "tech-preview.h" + +using namespace Qt::StringLiterals; + #ifdef Q_MOC_RUN // check that moc can parse these constructs, they are being used in Windows winsock2.h header #define STRING_HASH_HASH(x) ("foo" ## x ## "bar") @@ -71,12 +80,48 @@ const char *string_hash_hash = STRING_HASH_HASH("baz"); of writing this comment. */ namespace A::inline B {} +namespace A { + namespace B::inline C {} +} #endif + +namespace TokenStartingWithNumber +{ +Q_NAMESPACE + +#define FOR_EACH_ITEM( CALL ) \ + CALL( EXAMPLE ) \ + CALL( 123_EXAMPLE ) \ + CALL( OTHER_EXAMPLE ) + +enum FooItems +{ + +#define ENUM_ITEM(NAME, ...) FOO ## NAME, + FOR_EACH_ITEM( ENUM_ITEM ) +}; + +Q_ENUM_NS(FooItems) +} + Q_DECLARE_METATYPE(const QMetaObject*); #define TESTEXPORTMACRO Q_DECL_EXPORT +#if !defined(Q_MOC_RUN) && !defined(Q_NOREPLY) +# define Q_NOREPLY +#endif + +struct TagTest : QObject { + Q_OBJECT + + Q_INVOKABLE Q_NOREPLY inline int test() {return 0;} +public slots: + Q_NOREPLY virtual inline void pamOpen(int){} +}; + + namespace TestNonQNamespace { struct TestGadget { @@ -94,6 +139,12 @@ public: Key2 }; Q_ENUM(TestGEnum2) + + enum TestGEnum3: quint8 { + Key1 = 23, + Key2 + }; + Q_ENUM(TestGEnum3) }; } @@ -112,6 +163,12 @@ namespace TestQNamespace { }; Q_ENUM_NS(TestEnum2) + enum TestEnum3: qint8 { + Key1 = 23, + Key2 + }; + Q_ENUM_NS(TestEnum3) + // try to dizzy moc by adding a struct in between struct TestGadget { Q_GADGET @@ -124,8 +181,13 @@ namespace TestQNamespace { Key1 = 23, Key2 }; + enum TestGEnum3: qint16 { + Key1 = 33, + Key2 + }; Q_ENUM(TestGEnum1) Q_ENUM(TestGEnum2) + Q_ENUM(TestGEnum3) }; struct TestGadgetExport { @@ -142,6 +204,12 @@ namespace TestQNamespace { Key2 }; Q_ENUM(TestGeEnum2) + enum TestGeEnum3: quint16 { + Key1 = 26, + Key2 + }; + Q_ENUM(TestGeEnum3) + }; enum class TestFlag1 { @@ -161,6 +229,27 @@ namespace TestQNamespace { Q_FLAG_NS(TestFlag2) } +namespace TestSameEnumNamespace { + Q_NAMESPACE + + enum class TestSameEnumNamespace { + Key1 = 1, + Key2 = 2, + }; + Q_ENUM_NS(TestSameEnumNamespace) +} + +namespace TestNestedSameEnumNamespace { +namespace a { + Q_NAMESPACE + // enum class with the same name as the enclosing nested namespace + enum class a { + Key11 = 11, + Key12 = 12, + }; + Q_ENUM_NS(a) +} +} namespace TestExportNamespace { Q_NAMESPACE_EXPORT(TESTEXPORTMACRO) @@ -191,6 +280,24 @@ public: CreatableGadget creatableGadget; // Force the compiler to use the constructor +struct ParentWithSignalWithArgument : QObject { + Q_OBJECT + Q_PROPERTY(int i READ i WRITE setI NOTIFY iChanged) + +public: + int i() const {return 0;} + void setI(int) {} + +signals: + void iChanged(int); +}; + +struct SignalWithArgumentInParent : ParentWithSignalWithArgument +{ + Q_OBJECT + Q_PROPERTY(int otherI READ i WRITE setI NOTIFY iChanged) +}; + struct MyStruct {}; struct MyStruct2 {}; @@ -575,6 +682,10 @@ private slots: QT_WARNING_POP +// quick test to verify that moc handles the L suffix +// correctly in the preprocessor +#if 2000L < 1 +#else class PropertyTestClass : public QObject { Q_OBJECT @@ -584,6 +695,7 @@ public: Q_ENUM(TestEnum) }; +#endif class PropertyUseClass : public QObject { @@ -702,6 +814,7 @@ private slots: void templateGtGt(); void qprivateslots(); void qprivateproperties(); + void anonymousProperties(); void warnOnPropertyWithoutREAD(); void constructors(); void typenameWithUnsigned(); @@ -746,6 +859,7 @@ private slots: void optionsFileError_data(); void optionsFileError(); void testQNamespace(); + void testNestedQNamespace(); void cxx17Namespaces(); void cxxAttributes(); void mocJsonOutput(); @@ -756,6 +870,9 @@ private slots: void setQPRopertyBinding(); void privateQPropertyShim(); void readWriteThroughBindable(); + void invokableCtors(); + void virtualInlineTaggedSlot(); + void tokenStartingWithNumber(); signals: void sigWithUnsignedArg(unsigned foo); @@ -767,6 +884,7 @@ signals: void constSignal2(int arg) const; void member4Changed(); void member5Changed(const QString &newVal); + void sigWithDefaultArg(int i = 12); private: bool user1() { return true; }; @@ -792,6 +910,14 @@ private: }; +#define VERIFY_NO_ERRORS(proc) do { \ + auto &&p = proc; \ + const QByteArray stderr = p.readAllStandardError(); \ + QVERIFY2(stderr.isEmpty(), stderr.data()); \ + QCOMPARE(p.exitCode(), 0); \ + } while (false) + + void tst_Moc::initTestCase() { QString binpath = QLibraryInfo::path(QLibraryInfo::BinariesPath); @@ -806,10 +932,9 @@ void tst_Moc::initTestCase() QProcess proc; proc.start(qtpaths, QStringList() << "-query" << "QT_INSTALL_HEADERS"); QVERIFY(proc.waitForFinished()); - QCOMPARE(proc.exitCode(), 0); + VERIFY_NO_ERRORS(proc); QByteArray output = proc.readAllStandardOutput(); QVERIFY(!output.isEmpty()); - QCOMPARE(proc.readAllStandardError(), QByteArray()); qtIncludePath = QString::fromLocal8Bit(output).trimmed(); QFileInfo fi(qtIncludePath); QVERIFY(fi.exists()); @@ -844,10 +969,9 @@ void tst_Moc::oldStyleCasts() QProcess proc; proc.start(m_moc, QStringList(m_sourceDirectory + QStringLiteral("/oldstyle-casts.h"))); QVERIFY(proc.waitForFinished()); - QCOMPARE(proc.exitCode(), 0); + VERIFY_NO_ERRORS(proc); QByteArray mocOut = proc.readAllStandardOutput(); QVERIFY(!mocOut.isEmpty()); - QCOMPARE(proc.readAllStandardError(), QByteArray()); QStringList args; args << "-c" << "-x" << "c++" << "-Wold-style-cast" << "-I" << "." @@ -858,8 +982,7 @@ void tst_Moc::oldStyleCasts() proc.closeWriteChannel(); QVERIFY(proc.waitForFinished()); - QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardError()), QString()); - QCOMPARE(proc.exitCode(), 0); + VERIFY_NO_ERRORS(proc); #else QSKIP("Only tested on linux/gcc"); #endif @@ -916,10 +1039,9 @@ void tst_Moc::inputFileNameWithDotsButNoExtension() proc.setWorkingDirectory(m_sourceDirectory + QStringLiteral("/task71021")); proc.start(m_moc, QStringList("../Header")); QVERIFY(proc.waitForFinished()); - QCOMPARE(proc.exitCode(), 0); + VERIFY_NO_ERRORS(proc); QByteArray mocOut = proc.readAllStandardOutput(); QVERIFY(!mocOut.isEmpty()); - QCOMPARE(proc.readAllStandardError(), QByteArray()); QStringList args; args << "-c" << "-x" << "c++" << "-I" << ".." @@ -930,8 +1052,7 @@ void tst_Moc::inputFileNameWithDotsButNoExtension() proc.closeWriteChannel(); QVERIFY(proc.waitForFinished()); - QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardError()), QString()); - QCOMPARE(proc.exitCode(), 0); + VERIFY_NO_ERRORS(proc); #else QSKIP("Only tested on linux/gcc"); #endif @@ -954,12 +1075,12 @@ void tst_Moc::supportConstSignals() QSignalSpy spy1(this, SIGNAL(constSignal1())); QVERIFY(spy1.isEmpty()); emit constSignal1(); - QCOMPARE(spy1.count(), 1); + QCOMPARE(spy1.size(), 1); QSignalSpy spy2(this, SIGNAL(constSignal2(int))); QVERIFY(spy2.isEmpty()); emit constSignal2(42); - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy2.size(), 1); QCOMPARE(spy2.at(0).at(0).toInt(), 42); } @@ -1208,11 +1329,7 @@ void tst_Moc::ignoreOptionClashes() if (!finished) qWarning("waitForFinished failed. QProcess error: %d", (int)proc.error()); QVERIFY(finished); - if (proc.exitCode() != 0) { - qDebug() << proc.readAllStandardError(); - } - QCOMPARE(proc.exitCode(), 0); - QCOMPARE(proc.readAllStandardError(), QByteArray()); + VERIFY_NO_ERRORS(proc); QByteArray mocOut = proc.readAllStandardOutput(); // If -pthread wasn't ignored, it was parsed as a prefix of "thread/", which breaks compilation. @@ -1226,7 +1343,7 @@ void tst_Moc::ignoreOptionClashes() proc.closeWriteChannel(); QVERIFY(proc.waitForFinished()); - QCOMPARE(QString::fromLocal8Bit(proc.readAllStandardError()), QString()); + VERIFY_NO_ERRORS(proc); #else QSKIP("Only tested on linux/gcc"); #endif @@ -1331,11 +1448,7 @@ void tst_Moc::frameworkSearchPath() if (!finished) qWarning("waitForFinished failed. QProcess error: %d", (int)proc.error()); QVERIFY(finished); - if (proc.exitCode() != 0) { - qDebug() << proc.readAllStandardError(); - } - QCOMPARE(proc.exitCode(), 0); - QCOMPARE(proc.readAllStandardError(), QByteArray()); + VERIFY_NO_ERRORS(proc); #else QSKIP("Only tested/relevant on unixy platforms"); #endif @@ -1367,11 +1480,9 @@ void tst_Moc::templateGtGt() QProcess proc; proc.start(m_moc, QStringList(m_sourceDirectory + QStringLiteral("/template-gtgt.h"))); QVERIFY(proc.waitForFinished()); - QCOMPARE(proc.exitCode(), 0); + VERIFY_NO_ERRORS(proc); QByteArray mocOut = proc.readAllStandardOutput(); QVERIFY(!mocOut.isEmpty()); - QString mocWarning = QString::fromLocal8Bit(proc.readAllStandardError()); - QVERIFY(mocWarning.isEmpty()); #else QSKIP("Only tested on unix/gcc"); #endif @@ -1388,8 +1499,7 @@ void tst_Moc::defineMacroViaCmdline() proc.start(m_moc, args); QVERIFY(proc.waitForFinished()); - QCOMPARE(proc.exitCode(), 0); - QCOMPARE(proc.readAllStandardError(), QByteArray()); + VERIFY_NO_ERRORS(proc); QByteArray mocOut = proc.readAllStandardOutput(); QVERIFY(!mocOut.isEmpty()); #else @@ -1408,8 +1518,7 @@ void tst_Moc::defineMacroViaForcedInclude() proc.start(m_moc, args); QVERIFY(proc.waitForFinished()); - QCOMPARE(proc.exitCode(), 0); - QCOMPARE(proc.readAllStandardError(), QByteArray()); + VERIFY_NO_ERRORS(proc); QByteArray mocOut = proc.readAllStandardOutput(); QVERIFY(!mocOut.isEmpty()); #else @@ -1428,8 +1537,7 @@ void tst_Moc::defineMacroViaForcedIncludeRelative() proc.start(m_moc, args); QVERIFY(proc.waitForFinished()); - QCOMPARE(proc.exitCode(), 0); - QCOMPARE(proc.readAllStandardError(), QByteArray()); + VERIFY_NO_ERRORS(proc); QByteArray mocOut = proc.readAllStandardOutput(); QVERIFY(!mocOut.isEmpty()); #else @@ -1474,8 +1582,7 @@ void tst_Moc::environmentIncludePaths() proc.setProcessEnvironment(env); proc.start(m_moc, args); QVERIFY(proc.waitForFinished()); - QCOMPARE(proc.exitCode(), 0); - QCOMPARE(proc.readAllStandardError(), QByteArray()); + VERIFY_NO_ERRORS(proc); QByteArray mocOut = proc.readAllStandardOutput(); QVERIFY(!mocOut.isEmpty()); #else @@ -1498,7 +1605,8 @@ public: static StaticPluginInstance staticInstance; void tst_Moc::specifyMetaTagsFromCmdline() { - foreach (const QStaticPlugin &plugin, QPluginLoader::staticPlugins()) { + const auto staticPlugins = QPluginLoader::staticPlugins(); + for (const QStaticPlugin &plugin : staticPlugins) { const QString iid = plugin.metaData().value(QLatin1String("IID")).toString(); if (iid == QLatin1String("test.meta.tags")) { const QJsonArray metaTagsUriList = plugin.metaData().value("uri").toArray(); @@ -1516,41 +1624,43 @@ void tst_Moc::specifyMetaTagsFromCmdline() { void tst_Moc::invokable() { + const int fooIndex = 4; { const QMetaObject &mobj = InvokableBeforeReturnType::staticMetaObject; - QCOMPARE(mobj.methodCount(), 6); - QCOMPARE(mobj.method(5).methodSignature(), QByteArray("foo()")); + QCOMPARE(mobj.methodCount(), 5); + QCOMPARE(mobj.method(fooIndex).methodSignature(), QByteArray("foo()")); } { const QMetaObject &mobj = InvokableBeforeInline::staticMetaObject; - QCOMPARE(mobj.methodCount(), 7); - QCOMPARE(mobj.method(5).methodSignature(), QByteArray("foo()")); - QCOMPARE(mobj.method(6).methodSignature(), QByteArray("bar()")); + QCOMPARE(mobj.methodCount(), 6); + QCOMPARE(mobj.method(fooIndex).methodSignature(), QByteArray("foo()")); + QCOMPARE(mobj.method(fooIndex + 1).methodSignature(), QByteArray("bar()")); } } void tst_Moc::singleFunctionKeywordSignalAndSlot() { + const int mySignalIndex = 4; { const QMetaObject &mobj = SingleFunctionKeywordBeforeReturnType::staticMetaObject; - QCOMPARE(mobj.methodCount(), 7); - QCOMPARE(mobj.method(5).methodSignature(), QByteArray("mySignal()")); - QCOMPARE(mobj.method(6).methodSignature(), QByteArray("mySlot()")); + QCOMPARE(mobj.methodCount(), 6); + QCOMPARE(mobj.method(mySignalIndex).methodSignature(), QByteArray("mySignal()")); + QCOMPARE(mobj.method(mySignalIndex + 1).methodSignature(), QByteArray("mySlot()")); } { const QMetaObject &mobj = SingleFunctionKeywordBeforeInline::staticMetaObject; - QCOMPARE(mobj.methodCount(), 7); - QCOMPARE(mobj.method(5).methodSignature(), QByteArray("mySignal()")); - QCOMPARE(mobj.method(6).methodSignature(), QByteArray("mySlot()")); + QCOMPARE(mobj.methodCount(), 6); + QCOMPARE(mobj.method(mySignalIndex).methodSignature(), QByteArray("mySignal()")); + QCOMPARE(mobj.method(mySignalIndex + 1).methodSignature(), QByteArray("mySlot()")); } { const QMetaObject &mobj = SingleFunctionKeywordAfterInline::staticMetaObject; - QCOMPARE(mobj.methodCount(), 7); - QCOMPARE(mobj.method(5).methodSignature(), QByteArray("mySignal()")); - QCOMPARE(mobj.method(6).methodSignature(), QByteArray("mySlot()")); + QCOMPARE(mobj.methodCount(), 6); + QCOMPARE(mobj.method(mySignalIndex).methodSignature(), QByteArray("mySignal()")); + QCOMPARE(mobj.method(mySignalIndex + 1).methodSignature(), QByteArray("mySlot()")); } } @@ -1638,6 +1748,54 @@ void tst_Moc::qprivateproperties() QVERIFY(zapBindable.isBindable()); } + +class AnonymousPropertyTest1 : public QObject +{ + Q_OBJECT + QT_ANONYMOUS_PROPERTY(int READ foo WRITE setFoo) +public: + int foo() { return mFoo ; } + void setFoo(int value) { mFoo = value; } + +private: + int mFoo = 0; +}; + +class AnonymousPropertyTest2 : public QObject +{ + Q_OBJECT + QT_ANONYMOUS_PRIVATE_PROPERTY(d, int READ bar WRITE setBar) + + class MyDPointer { + public: + int bar() { return mBar ; } + void setBar(int value) { mBar = value; } + private: + int mBar = 0; + }; + +public: + AnonymousPropertyTest2(QObject *parent = nullptr) : QObject(parent), d (new MyDPointer) {} + MyDPointer *d_func() {return d.data();} + const MyDPointer *d_func() const {return d.data();} + +private: + QScopedPointer<MyDPointer> d; +}; + +void tst_Moc::anonymousProperties() +{ + AnonymousPropertyTest1 test1; + + test1.setProperty("", 17); + QCOMPARE(test1.property(""), QVariant::fromValue(17)); + + AnonymousPropertyTest2 test2; + + test2.setProperty("", 27); + QCOMPARE(test2.property(""), QVariant::fromValue(27)); +} + void tst_Moc::warnOnPropertyWithoutREAD() { #ifdef MOC_CROSS_COMPILED @@ -1882,11 +2040,10 @@ void tst_Moc::notifyError() const QString header = m_sourceDirectory + QStringLiteral("/error-on-wrong-notify.h"); proc.start(m_moc, QStringList(header)); QVERIFY(proc.waitForFinished()); - QCOMPARE(proc.exitCode(), 0); + VERIFY_NO_ERRORS(proc); QCOMPARE(proc.exitStatus(), QProcess::NormalExit); QByteArray mocOut = proc.readAllStandardOutput(); QVERIFY(!mocOut.isEmpty()); - QCOMPARE(proc.readAllStandardError(), QByteArray()); QStringList args; args << "-c" << "-x" << "c++" << "-I" << "." @@ -2104,7 +2261,7 @@ void tst_Moc::warnings_data() << QStringList() << 0 << QString() - << QString("standard input:0:1: note: No relevant classes found. No output generated."); + << QString("standard input: note: No relevant classes found. No output generated."); // passing "-nn" should suppress "no relevant classes" note QTest::newRow("-nn") @@ -2246,7 +2403,7 @@ void tst_Moc::warnings_data() << QStringList() << 1 << QString("IGNORE_ALL_STDOUT") - << QString(":-1:1: error: Unexpected character in macro argument list."); + << QString(": error: Unexpected character in macro argument list."); QTest::newRow("Missing header warning") << QByteArray("class X : public QObject { Q_OBJECT };") @@ -2293,6 +2450,13 @@ void tst_Moc::warnings_data() << QString() << QString("standard input:3:1: error: Parse error at \"decltype\""); + QTest::newRow("QTBUG-36367: report correct error location") + << "class X { \n Q_PROPERTY(Foo* foo NONSENSE foo) \n };"_ba + << QStringList() + << 1 + << QString() + << u"standard input:2:1: error: Parse error at \"NONSENSE\""_s; + #ifdef Q_OS_UNIX // Limit to Unix because the error message is platform-dependent QTest::newRow("Q_PLUGIN_METADATA: unreadable file") << QByteArray("class X { \n Q_PLUGIN_METADATA(FILE \".\") \n };") @@ -2373,23 +2537,29 @@ void tst_Moc::cxx11Enums_data() QTest::addColumn<QByteArray>("enumName"); QTest::addColumn<char>("prefix"); QTest::addColumn<bool>("isScoped"); + QTest::addColumn<bool>("isTyped"); const QMetaObject *meta1 = &CXX11Enums::staticMetaObject; const QMetaObject *meta2 = &CXX11Enums2::staticMetaObject; - - QTest::newRow("EnumClass") << meta1 << QByteArray("EnumClass") << QByteArray("EnumClass") << 'A' << true; - QTest::newRow("EnumClass 2") << meta2 << QByteArray("EnumClass") << QByteArray("EnumClass") << 'A' << true; - QTest::newRow("TypedEnum") << meta1 << QByteArray("TypedEnum") << QByteArray("TypedEnum") << 'B' << false; - QTest::newRow("TypedEnum 2") << meta2 << QByteArray("TypedEnum") << QByteArray("TypedEnum") << 'B' << false; - QTest::newRow("TypedEnumClass") << meta1 << QByteArray("TypedEnumClass") << QByteArray("TypedEnumClass") << 'C' << true; - QTest::newRow("TypedEnumClass 2") << meta2 << QByteArray("TypedEnumClass") << QByteArray("TypedEnumClass") << 'C' << true; - QTest::newRow("NormalEnum") << meta1 << QByteArray("NormalEnum") << QByteArray("NormalEnum") << 'D' << false; - QTest::newRow("NormalEnum 2") << meta2 << QByteArray("NormalEnum") << QByteArray("NormalEnum") << 'D' << false; - QTest::newRow("ClassFlags") << meta1 << QByteArray("ClassFlags") << QByteArray("ClassFlag") << 'F' << true; - QTest::newRow("ClassFlags 2") << meta2 << QByteArray("ClassFlags") << QByteArray("ClassFlag") << 'F' << true; - QTest::newRow("EnumStruct") << meta1 << QByteArray("EnumStruct") << QByteArray("EnumStruct") << 'G' << true; - QTest::newRow("TypedEnumStruct") << meta1 << QByteArray("TypedEnumStruct") << QByteArray("TypedEnumStruct") << 'H' << true; - QTest::newRow("StructFlags") << meta1 << QByteArray("StructFlags") << QByteArray("StructFlag") << 'I' << true; + const QMetaObject *meta3 = &CXX11Enums3::staticMetaObject; + + QTest::newRow("EnumClass") << meta1 << QByteArray("EnumClass") << QByteArray("EnumClass") << 'A' << true << false; + QTest::newRow("EnumClass 2") << meta2 << QByteArray("EnumClass") << QByteArray("EnumClass") << 'A' << true << false; + QTest::newRow("EnumClass 3") << meta3 << QByteArray("EnumClass") << QByteArray("EnumClass") << 'A' << true << false; + QTest::newRow("TypedEnum") << meta1 << QByteArray("TypedEnum") << QByteArray("TypedEnum") << 'B' << false << true; + QTest::newRow("TypedEnum 2") << meta2 << QByteArray("TypedEnum") << QByteArray("TypedEnum") << 'B' << false << true; + QTest::newRow("TypedEnum 3") << meta3 << QByteArray("TypedEnum") << QByteArray("TypedEnum") << 'B' << false << true; + QTest::newRow("TypedEnumClass") << meta1 << QByteArray("TypedEnumClass") << QByteArray("TypedEnumClass") << 'C' << true << true; + QTest::newRow("TypedEnumClass 2") << meta2 << QByteArray("TypedEnumClass") << QByteArray("TypedEnumClass") << 'C' << true << true; + QTest::newRow("TypedEnumClass 3") << meta3 << QByteArray("TypedEnumClass") << QByteArray("TypedEnumClass") << 'C' << true << true; + QTest::newRow("NormalEnum") << meta1 << QByteArray("NormalEnum") << QByteArray("NormalEnum") << 'D' << false << false; + QTest::newRow("NormalEnum 2") << meta2 << QByteArray("NormalEnum") << QByteArray("NormalEnum") << 'D' << false << false; + QTest::newRow("NormalEnum 3") << meta3 << QByteArray("NormalEnum") << QByteArray("NormalEnum") << 'D' << false << false; + QTest::newRow("ClassFlags") << meta1 << QByteArray("ClassFlags") << QByteArray("ClassFlag") << 'F' << true << false; + QTest::newRow("ClassFlags 2") << meta2 << QByteArray("ClassFlags") << QByteArray("ClassFlag") << 'F' << true << false; + QTest::newRow("EnumStruct") << meta1 << QByteArray("EnumStruct") << QByteArray("EnumStruct") << 'G' << true << false; + QTest::newRow("TypedEnumStruct") << meta1 << QByteArray("TypedEnumStruct") << QByteArray("TypedEnumStruct") << 'H' << true << true; + QTest::newRow("StructFlags") << meta1 << QByteArray("StructFlags") << QByteArray("StructFlag") << 'I' << true << false; } void tst_Moc::cxx11Enums() @@ -2401,24 +2571,39 @@ void tst_Moc::cxx11Enums() QFETCH(QByteArray, enumName); QFETCH(char, prefix); QFETCH(bool, isScoped); + QFETCH(bool, isTyped); int idx = meta->indexOfEnumerator(typeName); QVERIFY(idx != -1); QCOMPARE(meta->indexOfEnumerator(enumName), idx); - QCOMPARE(meta->enumerator(idx).enclosingMetaObject(), meta); - QCOMPARE(meta->enumerator(idx).isValid(), true); - QCOMPARE(meta->enumerator(idx).keyCount(), 4); - QCOMPARE(meta->enumerator(idx).name(), typeName.constData()); - QCOMPARE(meta->enumerator(idx).enumName(), enumName.constData()); - bool isFlag = meta->enumerator(idx).isFlag(); + const QMetaEnum metaEnum = meta->enumerator(idx); + QCOMPARE(metaEnum.enclosingMetaObject(), meta); + QCOMPARE(metaEnum.isValid(), true); + QCOMPARE(metaEnum.keyCount(), 4); + QCOMPARE(metaEnum.name(), typeName.constData()); + QCOMPARE(metaEnum.enumName(), enumName.constData()); + + const QMetaType metaType = metaEnum.metaType(); + const bool isUnsigned = metaType.flags() & QMetaType::IsUnsignedEnumeration; + if (isTyped) { + QCOMPARE(size_t(metaType.sizeOf()), sizeof(char)); + QCOMPARE(isUnsigned, !std::is_signed_v<char>); + } else if (isScoped) { + QCOMPARE(size_t(metaType.sizeOf()), sizeof(int)); + QCOMPARE(isUnsigned, !std::is_signed_v<int>); + } else { + // underlying type is implementation defined + } + + bool isFlag = metaEnum.isFlag(); for (int i = 0; i < 4; i++) { QByteArray v = prefix + QByteArray::number(i); const int value = isFlag ? (1 << i) : i; - QCOMPARE(meta->enumerator(idx).keyToValue(v), value); - QCOMPARE(meta->enumerator(idx).valueToKey(value), v.constData()); + QCOMPARE(metaEnum.keyToValue(v), value); + QCOMPARE(metaEnum.valueToKey(value), v.constData()); } - QCOMPARE(meta->enumerator(idx).isScoped(), isScoped); + QCOMPARE(metaEnum.isScoped(), isScoped); } void tst_Moc::cxx11TrailingReturn() @@ -2513,7 +2698,7 @@ void tst_Moc::memberProperties() if (!signal.isEmpty()) { - QCOMPARE(notifySpy.count(), 1); + QCOMPARE(notifySpy.size(), 1); if (prop.notifySignal().parameterNames().size() > 0) { QList<QVariant> arguments = notifySpy.takeFirst(); QCOMPARE(arguments.size(), 1); @@ -2523,7 +2708,7 @@ void tst_Moc::memberProperties() notifySpy.clear(); // a second write with the same value should not cause the signal to be emitted again QCOMPARE(prop.write(pObj, writeValue), expectedWriteResult); - QCOMPARE(notifySpy.count(), 0); + QCOMPARE(notifySpy.size(), 0); } } @@ -3603,10 +3788,9 @@ void tst_Moc::preprocessorOnly() QProcess proc; proc.start(m_moc, QStringList() << "-E" << m_sourceDirectory + QStringLiteral("/pp-dollar-signs.h")); QVERIFY(proc.waitForFinished()); - QCOMPARE(proc.exitCode(), 0); + VERIFY_NO_ERRORS(proc); QByteArray mocOut = proc.readAllStandardOutput(); QVERIFY(!mocOut.isEmpty()); - QCOMPARE(proc.readAllStandardError(), QByteArray()); QVERIFY(mocOut.contains("$$ = parser->createFoo()")); #else @@ -3757,7 +3941,7 @@ void tst_Moc::relatedMetaObjectsNameConflict() { typedef QList<const QMetaObject *> QMetaObjects; QFETCH(const QMetaObject*, dependingObject); - QFETCH(QMetaObjects, relatedMetaObjects); + QFETCH(const QMetaObjects, relatedMetaObjects); // load all specified metaobjects int a set QSet<const QMetaObject*> dependency; @@ -3768,7 +3952,7 @@ void tst_Moc::relatedMetaObjectsNameConflict() } // check if all required metaobjects are specified - foreach (const QMetaObject *mo, relatedMetaObjects) + for (const QMetaObject *mo : relatedMetaObjects) QVERIFY(dependency.contains(mo)); // check if no additional metaobjects ara specified @@ -3939,10 +4123,12 @@ void tst_Moc::optionsFileError() } static void checkEnum(const QMetaEnum &enumerator, const QByteArray &name, - const QList<QPair<QByteArray, int>> &keys) + const QList<QPair<QByteArray, int>> &keys, + const QMetaType underlyingType = QMetaType::fromType<int>()) { QCOMPARE(name, QByteArray{enumerator.name()}); QCOMPARE(keys.size(), enumerator.keyCount()); + QCOMPARE(underlyingType, enumerator.metaType().underlyingType()); for (int i = 0; i < enumerator.keyCount(); ++i) { QCOMPARE(keys[i].first, QByteArray{enumerator.key(i)}); QCOMPARE(keys[i].second, enumerator.value(i)); @@ -3957,29 +4143,57 @@ public: FooNamespace::Enum1 prop() { return FooNamespace::Enum1::Key2; } }; +void tst_Moc::testNestedQNamespace() +{ + QCOMPARE(TestSameEnumNamespace::staticMetaObject.enumeratorCount(), 1); + checkEnum(TestSameEnumNamespace::staticMetaObject.enumerator(0), "TestSameEnumNamespace", + {{"Key1", 1}, {"Key2", 2}}); + QMetaEnum meta1 = QMetaEnum::fromType<TestSameEnumNamespace::TestSameEnumNamespace>(); + QVERIFY(meta1.isValid()); + QCOMPARE(meta1.name(), "TestSameEnumNamespace"); + QCOMPARE(meta1.enclosingMetaObject(), &TestSameEnumNamespace::staticMetaObject); + QCOMPARE(meta1.keyCount(), 2); + + // QTBUG-112996 + QCOMPARE(TestNestedSameEnumNamespace::a::staticMetaObject.enumeratorCount(), 1); + checkEnum(TestNestedSameEnumNamespace::a::staticMetaObject.enumerator(0), "a", + {{"Key11", 11}, {"Key12", 12}}); + QMetaEnum meta2 = QMetaEnum::fromType<TestNestedSameEnumNamespace::a::a>(); + QVERIFY(meta2.isValid()); + QCOMPARE(meta2.name(), "a"); + QCOMPARE(meta2.enclosingMetaObject(), &TestNestedSameEnumNamespace::a::staticMetaObject); + QCOMPARE(meta2.keyCount(), 2); +} + void tst_Moc::testQNamespace() { - QCOMPARE(TestQNamespace::staticMetaObject.enumeratorCount(), 4); + QCOMPARE(TestQNamespace::staticMetaObject.enumeratorCount(), 5); checkEnum(TestQNamespace::staticMetaObject.enumerator(0), "TestEnum1", {{"Key1", 11}, {"Key2", 12}}); checkEnum(TestQNamespace::staticMetaObject.enumerator(1), "TestEnum2", {{"Key1", 17}, {"Key2", 18}}); - checkEnum(TestQNamespace::staticMetaObject.enumerator(2), "TestFlag1", + checkEnum(TestQNamespace::staticMetaObject.enumerator(2), "TestEnum3", + {{"Key1", 23}, {"Key2", 24}}, QMetaType::fromType<qint8>()); + checkEnum(TestQNamespace::staticMetaObject.enumerator(3), "TestFlag1", {{"None", 0}, {"Flag1", 1}, {"Flag2", 2}, {"Any", 1 | 2}}); - checkEnum(TestQNamespace::staticMetaObject.enumerator(3), "TestFlag2", + checkEnum(TestQNamespace::staticMetaObject.enumerator(4), "TestFlag2", {{"None", 0}, {"Flag1", 4}, {"Flag2", 8}, {"Any", 4 | 8}}); - QCOMPARE(TestQNamespace::TestGadget::staticMetaObject.enumeratorCount(), 2); + QCOMPARE(TestQNamespace::TestGadget::staticMetaObject.enumeratorCount(), 3); checkEnum(TestQNamespace::TestGadget::staticMetaObject.enumerator(0), "TestGEnum1", {{"Key1", 13}, {"Key2", 14}}); checkEnum(TestQNamespace::TestGadget::staticMetaObject.enumerator(1), "TestGEnum2", {{"Key1", 23}, {"Key2", 24}}); + checkEnum(TestQNamespace::TestGadget::staticMetaObject.enumerator(2), "TestGEnum3", + {{"Key1", 33}, {"Key2", 34}}, QMetaType::fromType<qint16>()); - QCOMPARE(TestQNamespace::TestGadgetExport::staticMetaObject.enumeratorCount(), 2); + QCOMPARE(TestQNamespace::TestGadgetExport::staticMetaObject.enumeratorCount(), 3); checkEnum(TestQNamespace::TestGadgetExport::staticMetaObject.enumerator(0), "TestGeEnum1", {{"Key1", 20}, {"Key2", 21}}); checkEnum(TestQNamespace::TestGadgetExport::staticMetaObject.enumerator(1), "TestGeEnum2", {{"Key1", 23}, {"Key2", 24}}); + checkEnum(TestQNamespace::TestGadgetExport::staticMetaObject.enumerator(2), "TestGeEnum3", + {{"Key1", 26}, {"Key2", 27}}, QMetaType::fromType<quint16>()); QMetaEnum meta = QMetaEnum::fromType<TestQNamespace::TestEnum1>(); QVERIFY(meta.isValid()); @@ -4022,7 +4236,9 @@ void tst_Moc::cxx17Namespaces() void tst_Moc::cxxAttributes() { +QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED auto so = CppAttribute::staticMetaObject; +QT_WARNING_POP QCOMPARE(so.className(), "CppAttribute"); QCOMPARE(so.enumeratorCount(), 0); QVERIFY(so.indexOfSignal("deprecatedSignal") != 1); @@ -4057,9 +4273,12 @@ void tst_Moc::cxxAttributes() void tst_Moc::mocJsonOutput() { - const auto readFile = [](const QString &fileName) { + const auto readFile = [](const QString &fileName) -> std::optional<QJsonDocument> { QFile f(fileName); - f.open(QIODevice::ReadOnly); + if (!f.open(QIODevice::ReadOnly)) { + qWarning() << "Could not open file" << fileName << f.errorString(); + return std::nullopt; + } return QJsonDocument::fromJson(f.readAll()); }; @@ -4075,8 +4294,10 @@ void tst_Moc::mocJsonOutput() QVERIFY2(QFile::exists(actualFile), qPrintable(actualFile)); QVERIFY2(QFile::exists(expectedFile), qPrintable(expectedFile)); - QJsonDocument actualOutput = readFile(actualFile); - QJsonDocument expectedOutput = readFile(expectedFile); + std::optional<QJsonDocument> actualOutput = readFile(actualFile); + QVERIFY(actualOutput); + std::optional<QJsonDocument> expectedOutput = readFile(expectedFile); + QVERIFY(expectedOutput); const auto showPotentialDiff = [](const QJsonDocument &actual, const QJsonDocument &expected) -> QByteArray { #if defined(Q_OS_UNIX) @@ -4105,11 +4326,13 @@ void tst_Moc::mocJsonOutput() return "Error waiting for diff process to finish."; return diffProc.readAllStandardOutput(); #else + Q_UNUSED(actual); + Q_UNUSED(expected); return "Cannot launch diff. Please check allmocs.json and allmocs_baseline.json on disk."; #endif }; - QVERIFY2(actualOutput == expectedOutput, showPotentialDiff(actualOutput, expectedOutput).constData()); + QVERIFY2(*actualOutput == *expectedOutput, showPotentialDiff(*actualOutput, *expectedOutput).constData()); } void TestFwdProperties::setProp1(const FwdClass1 &v) @@ -4205,7 +4428,7 @@ void tst_Moc::qpropertyMembers() instance.publicProperty.setValue(100); QCOMPARE(prop.read(&instance).toInt(), 100); - QCOMPARE(publicPropertySpy.count(), 1); + QCOMPARE(publicPropertySpy.size(), 1); QCOMPARE(prop.metaType(), QMetaType(QMetaType::Int)); @@ -4421,6 +4644,65 @@ void tst_Moc::readWriteThroughBindable() } } +struct WithInvokableCtor +{ + Q_GADGET + Q_PROPERTY(int thing MEMBER m_thing CONSTANT FINAL) +public: + WithInvokableCtor() = default; + Q_INVOKABLE WithInvokableCtor(int theThing) : m_thing(theThing) {} + + int m_thing = 10; +}; + +void tst_Moc::invokableCtors() +{ + const QMetaType metaType = QMetaType::fromType<WithInvokableCtor>(); + Q_ASSERT(metaType.sizeOf() > 0); + const QMetaObject *metaObject = metaType.metaObject(); + QVERIFY(metaObject); + + QCOMPARE(metaObject->constructorCount(), 1); + WithInvokableCtor *result = nullptr; + const auto guard = qScopeGuard([&]() { delete result; }); + int argument = 17; + void *a[] = { &result, &argument }; + metaObject->static_metacall(QMetaObject::CreateInstance, 0, a); + QVERIFY(result); + QCOMPARE(result->m_thing, 17); + + // Call dtor so that we're left with "uninitialized" memory. + WithInvokableCtor result2; + result2.~WithInvokableCtor(); + + void *b[] = { &result2, &argument }; + metaObject->static_metacall(QMetaObject::ConstructInPlace, 0, b); + QCOMPARE(result2.m_thing, 17); +} + +void tst_Moc::virtualInlineTaggedSlot() +{ + auto mo = TagTest::staticMetaObject; + auto idx = mo.indexOfMethod("pamOpen(int)"); + auto method = mo.method(idx); + QVERIFY(method.isValid()); // fails! + QCOMPARE(method.tag(), "Q_NOREPLY"); + idx = mo.indexOfMethod("test()"); + method = mo.method(idx); + QVERIFY(method.isValid()); + QCOMPARE(method.tag(), "Q_NOREPLY"); + QCOMPARE(method.returnMetaType(), QMetaType::fromType<int>()); +} + +void tst_Moc::tokenStartingWithNumber() +{ + auto *mo = &TokenStartingWithNumber::staticMetaObject; + int index = mo->indexOfEnumerator("FooItems"); + QMetaEnum metaEnum = mo->enumerator(index); + QVERIFY(metaEnum.isValid()); + QCOMPARE(metaEnum.keyCount(), 3); +} + QTEST_MAIN(tst_Moc) // the generated code must compile with QT_NO_KEYWORDS diff --git a/tests/auto/tools/moc/unterminated-function-macro.h b/tests/auto/tools/moc/unterminated-function-macro.h index e81ce34394..2cb0579449 100644 --- a/tests/auto/tools/moc/unterminated-function-macro.h +++ b/tests/auto/tools/moc/unterminated-function-macro.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef UNTERMINATED_FUNCTION_MACRO_H #define UNTERMINATED_FUNCTION_MACRO_H diff --git a/tests/auto/tools/moc/using-namespaces.h b/tests/auto/tools/moc/using-namespaces.h index 3ca012116e..eaba403dff 100644 --- a/tests/auto/tools/moc/using-namespaces.h +++ b/tests/auto/tools/moc/using-namespaces.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef USING_NAMESPACES_H #define USING_NAMESPACES_H diff --git a/tests/auto/tools/moc/warn-on-multiple-qobject-subclasses.h b/tests/auto/tools/moc/warn-on-multiple-qobject-subclasses.h index 2e13c9a2de..0e45036768 100644 --- a/tests/auto/tools/moc/warn-on-multiple-qobject-subclasses.h +++ b/tests/auto/tools/moc/warn-on-multiple-qobject-subclasses.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WARN_ON_MULTIPLE_QOBJECT_SUBCLASSES_H #define WARN_ON_MULTIPLE_QOBJECT_SUBCLASSES_H diff --git a/tests/auto/tools/moc/warn-on-property-without-read.h b/tests/auto/tools/moc/warn-on-property-without-read.h index bd92412ec2..19a3a305bd 100644 --- a/tests/auto/tools/moc/warn-on-property-without-read.h +++ b/tests/auto/tools/moc/warn-on-property-without-read.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef WARN_ON_PROPERTY_WITHOUT_READ_H #define WARN_ON_PROPERTY_WITHOUT_READ_H diff --git a/tests/auto/tools/moc/win-newlines.h b/tests/auto/tools/moc/win-newlines.h index 6dcd575dae..353c21dbbb 100644 --- a/tests/auto/tools/moc/win-newlines.h +++ b/tests/auto/tools/moc/win-newlines.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QObject>
|