From b1b3af02c0fb8084d2eb984b1f7ae68f1861f9a4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 17 Jun 2024 07:38:45 +0200 Subject: [PATCH] tst_moc: fix 'inline function used but never defined' GCC warning GCC doesn't have a specific warning flag for this warning, so we can't add a GCC case to the existing Clang suppression in the header. Hovever, the issue can be fixed by including the moc file into tst_moc.cpp, so that the compiler sees the definition of the inline signal provided by the said moc file. This means we can also drop the Clang warning suppressions. To prevent duplicate definition linker errors, remove the header file from JSON_FILES, and the forced separate compilation that entails. I'm pretty sure that some cmake magic could preserve the JSON test coverage, but a) the file doesn't emit anything special in its json (certainly nothing about the inline'ness of the signals) and b) the presence of mySlot() and mySignal() as slot and signal on these classes is already tested by singleFunctionKeywordSignalAndSlot(). Amends the start of the public history, but not picking back far, because a) a prequel commit to this commit wasn't picked further, either, and b) this has been such a long-standing issue that it's clear no-one cares and so it's just not worth the risk, however small that may be, to backport. On GCC, the only remaining warnings thrown by tst_moc are now moc-generated ones. Pick-to: 6.8 Task-number: QTBUG-119042 Change-Id: Icde1eee6c97bd48d72e15461b6ec80c50c044eaa Reviewed-by: Fabian Kosmale Reviewed-by: Thiago Macieira --- tests/auto/tools/moc/CMakeLists.txt | 2 +- tests/auto/tools/moc/allmocs_baseline_in.json | 81 ------------------- .../auto/tools/moc/single_function_keyword.h | 6 -- tests/auto/tools/moc/tst_moc.cpp | 1 + 4 files changed, 2 insertions(+), 88 deletions(-) diff --git a/tests/auto/tools/moc/CMakeLists.txt b/tests/auto/tools/moc/CMakeLists.txt index 1377c48306a..a8df73bdf4c 100644 --- a/tests/auto/tools/moc/CMakeLists.txt +++ b/tests/auto/tools/moc/CMakeLists.txt @@ -46,7 +46,6 @@ set(JSON_HEADERS 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 task192552.h task234909.h @@ -71,6 +70,7 @@ list(TRANSFORM comparison_relevant_moc_list APPEND ".json" OUTPUT_VARIABLE moc_ qt_internal_add_test(tst_moc SOURCES cxx-attributes.h + single_function_keyword.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 5cbcb99e68f..f82500eda44 100644 --- a/tests/auto/tools/moc/allmocs_baseline_in.json +++ b/tests/auto/tools/moc/allmocs_baseline_in.json @@ -2603,87 +2603,6 @@ "inputFile": "single-quote-digit-separator-n3781.h", "outputRevision": 68 }, - { - "classes": [ - { - "className": "SingleFunctionKeywordBeforeReturnType", - "object": true, - "qualifiedClassName": "SingleFunctionKeywordBeforeReturnType", - "signals": [ - { - "access": "public", - "name": "mySignal", - "returnType": "void" - } - ], - "slots": [ - { - "access": "public", - "name": "mySlot", - "returnType": "void" - } - ], - "superClasses": [ - { - "access": "public", - "name": "QObject" - } - ] - }, - { - "className": "SingleFunctionKeywordBeforeInline", - "object": true, - "qualifiedClassName": "SingleFunctionKeywordBeforeInline", - "signals": [ - { - "access": "public", - "name": "mySignal", - "returnType": "void" - } - ], - "slots": [ - { - "access": "public", - "name": "mySlot", - "returnType": "void" - } - ], - "superClasses": [ - { - "access": "public", - "name": "QObject" - } - ] - }, - { - "className": "SingleFunctionKeywordAfterInline", - "object": true, - "qualifiedClassName": "SingleFunctionKeywordAfterInline", - "signals": [ - { - "access": "public", - "name": "mySignal", - "returnType": "void" - } - ], - "slots": [ - { - "access": "public", - "name": "mySlot", - "returnType": "void" - } - ], - "superClasses": [ - { - "access": "public", - "name": "QObject" - } - ] - } - ], - "inputFile": "single_function_keyword.h", - "outputRevision": 68 - }, { "classes": [ { diff --git a/tests/auto/tools/moc/single_function_keyword.h b/tests/auto/tools/moc/single_function_keyword.h index 0c907db9ef6..28fd9ab90af 100644 --- a/tests/auto/tools/moc/single_function_keyword.h +++ b/tests/auto/tools/moc/single_function_keyword.h @@ -22,10 +22,7 @@ class SingleFunctionKeywordBeforeInline : public QObject public: inline SingleFunctionKeywordBeforeInline() {} -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wundefined-inline") Q_SIGNAL inline void mySignal(); -QT_WARNING_POP Q_SLOT inline void mySlot() { emit mySignal(); } }; @@ -36,10 +33,7 @@ class SingleFunctionKeywordAfterInline : public QObject public: inline SingleFunctionKeywordAfterInline() {} -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wundefined-inline") inline Q_SIGNAL void mySignal(); -QT_WARNING_POP inline Q_SLOT void mySlot() { emit mySignal(); } }; diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index e1446cfe1ca..4fcb44f00c6 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -4721,3 +4721,4 @@ QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wvolatile") // should moc itself add this in generated code? #include "tst_moc.moc" QT_WARNING_POP +#include "moc_single_function_keyword.cpp" // prevents "undefined inline functions" warnings