diff options
author | Fabian Kosmale <[email protected]> | 2025-06-23 17:17:46 +0200 |
---|---|---|
committer | Fabian Kosmale <[email protected]> | 2025-06-25 20:36:16 +0200 |
commit | 48a22ad6728700bb45b4116f3d5f1e9feb8f93bf (patch) | |
tree | 67a325bae14a37967731072e55caeee511198dfd /tests/auto | |
parent | eab1295c8825def52fb1439abdb5e2ae71c378e7 (diff) |
moc: disable name clash bug for faulty MSVC verisons
We still want to test the code on non-affected MSVC versions, so we
- remove the header from the manual qt_wrap_cpp call,
- instead, let automoc pick it up by making it part of the target,
- include the moc file to prevent CMake putting the generated file
in the combined C++ file,
- but include it only conditionally to avoid the compilation issue on
MSVC.
This has the side effect that we no longer consider the file in the JSON
output, but that is less important.
Pick-to: 6.10 6.9
Change-Id: I46d93aac9721eba081221586b66a3742c863da90
Reviewed-by: Oliver Wolff <[email protected]>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/tools/moc/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/tools/moc/allmocs_baseline_in.json | 67 | ||||
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 19 |
3 files changed, 19 insertions, 69 deletions
diff --git a/tests/auto/tools/moc/CMakeLists.txt b/tests/auto/tools/moc/CMakeLists.txt index c8344dad081..13f22ced0fc 100644 --- a/tests/auto/tools/moc/CMakeLists.txt +++ b/tests/auto/tools/moc/CMakeLists.txt @@ -28,7 +28,6 @@ set(JSON_HEADERS gadgetwithnoenums.h grand-parent-gadget-class.h moc_include.h - name_collision.h namespace.h namespaced-flags.h namespaced-base-class.h @@ -75,6 +74,7 @@ qt_internal_add_test(tst_moc SOURCES cxx-attributes.h single_function_keyword.h + name_collision.h tst_moc.cpp ${comparison_relevant_moc_list} INCLUDE_DIRECTORIES diff --git a/tests/auto/tools/moc/allmocs_baseline_in.json b/tests/auto/tools/moc/allmocs_baseline_in.json index 28feba8dba9..c3425c6d15f 100644 --- a/tests/auto/tools/moc/allmocs_baseline_in.json +++ b/tests/auto/tools/moc/allmocs_baseline_in.json @@ -1380,73 +1380,6 @@ { "classes": [ { - "className": "NameCollision", - "lineNumber": 11, - "object": true, - "properties": [ - { - "constant": false, - "designable": true, - "final": false, - "index": 0, - "name": "Status", - "read": "Status", - "required": false, - "scriptable": true, - "stored": true, - "type": "Status", - "user": false, - "write": "setStatus" - }, - { - "constant": false, - "designable": true, - "final": false, - "index": 1, - "member": "m_decorationMode", - "name": "decorationMode", - "required": false, - "scriptable": true, - "stored": true, - "type": "DecorationMode", - "user": false - } - - ], - "qualifiedClassName": "myns::NameCollision", - "slots": [ - { - "access": "public", - "arguments": [ - { - "type": "Status" - } - ], - "index": 0, - "name": "setStatus", - "returnType": "void" - }, - { - "access": "public", - "index": 1, - "name": "Status", - "returnType": "Status" - } - ], - "superClasses": [ - { - "access": "public", - "name": "QObject" - } - ] - } - ], - "inputFile": "name_collision.h", - "outputRevision": 69 - }, - { - "classes": [ - { "className": "FooNamespace", "enums": [ { diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 9a428e59f06..ab88dd78111 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -3,6 +3,14 @@ // Copyright (C) 2024 Intel Corporation. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +/* upstream MSVC bug + https://developercommunity.visualstudio.com/t/Regression:-c-compilation-failure-in-c/10926790 +*/ +#include <QtCore/qcompilerdetection.h> +#if defined(Q_CC_MSVC_ONLY) && (_MSC_FULL_VER >= 194435209) && (_MSC_FULL_VER < 194500000) +# define MSVC_ENUM_BUG +#endif + #include <QTest> #include <QSignalSpy> #include <stdio.h> @@ -67,7 +75,9 @@ #include "tech-preview.h" -#include "name_collision.h" +#ifndef MSVC_ENUM_BUG +# include "name_collision.h" +#endif using namespace Qt::StringLiterals; @@ -989,7 +999,9 @@ void tst_Moc::initTestCase() QVERIFY(QmlMacro::staticMetaObject.className()); QVERIFY(SignalWithDefaultArg::staticMetaObject.className()); QVERIFY(TestPointeeCanBeIncomplete::staticMetaObject.className()); +#ifndef MSVC_ENUM_BUG QVERIFY(myns::NameCollision::staticMetaObject.className()); +#endif } void tst_Moc::hasIncludeSupport() @@ -4923,6 +4935,11 @@ QTEST_MAIN(tst_Moc) #undef slots #undef emit +// needs to be included conditionally +#ifndef MSVC_ENUM_BUG +#include "moc_name_collision.cpp" +#endif + QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wvolatile") // should moc itself add this in generated code? #include "tst_moc.moc" |