diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2024-05-06 11:27:53 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2024-05-06 11:15:47 +0000 |
commit | df3c82f6af0bf7b857ba7a5110643eb7abe84182 (patch) | |
tree | eb51eb69710e13b0a9fcb273c24e05d81d916158 | |
parent | f85d3f950a046d768d7644931ed8167d614ad19c (diff) |
QML macros: suppress Wredundant-decls
When using multiple QML type registration macros, one might end up with
duplicated friend declarations. This is fine as far as C++ is concerned,
but triggers gcc's redundant-decls warning.
Given that we require the friend declaration, and would like to keep it
in the macros that actually need them (instead of putting them into the
macros which are used in all types exposed to QML), we opt for
suppressing the warning.
Pick-to: 6.5 6.7
Fixes: QTBUG-124934
Change-Id: I4f43afddfefb6e546ddddbdc01435222398a06be
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/qmlintegration/qqmlintegration.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/qmlintegration/qqmlintegration.h b/src/qmlintegration/qqmlintegration.h index 1e40ceec17..f1a990a79c 100644 --- a/src/qmlintegration/qqmlintegration.h +++ b/src/qmlintegration/qqmlintegration.h @@ -45,12 +45,16 @@ QT_END_NAMESPACE #define QML_ELEMENT \ Q_CLASSINFO("QML.Element", "auto") + #define QML_ANONYMOUS \ Q_CLASSINFO("QML.Element", "anonymous") \ enum class QmlIsAnonymous{yes = true}; \ template<typename, typename> friend struct QML_PRIVATE_NAMESPACE::QmlAnonymous; \ + QT_WARNING_PUSH \ + QT_WARNING_DISABLE_GCC("-Wredundant-decls") \ template<typename... Args> \ friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \ + QT_WARNING_POP \ inline constexpr void qt_qmlMarker_anonymous() {} #define QML_NAMED_ELEMENT(NAME) \ @@ -61,8 +65,11 @@ QT_END_NAMESPACE Q_CLASSINFO("QML.UncreatableReason", REASON) \ enum class QmlIsUncreatable {yes = true}; \ template<typename, typename> friend struct QML_PRIVATE_NAMESPACE::QmlUncreatable; \ + QT_WARNING_PUSH \ + QT_WARNING_DISABLE_GCC("-Wredundant-decls") \ template<typename... Args> \ friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \ + QT_WARNING_POP \ inline constexpr void qt_qmlMarker_uncreatable() {} #define QML_VALUE_TYPE(NAME) \ @@ -80,8 +87,11 @@ QT_END_NAMESPACE Q_CLASSINFO("QML.Singleton", "true") \ enum class QmlIsSingleton {yes = true}; \ template<typename, typename> friend struct QML_PRIVATE_NAMESPACE::QmlSingleton; \ + QT_WARNING_PUSH \ + QT_WARNING_DISABLE_GCC("-Wredundant-decls") \ template<typename... Args> \ friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \ + QT_WARNING_POP \ inline constexpr void qt_qmlMarker_singleton() {} #define QML_ADDED_IN_MINOR_VERSION(VERSION) \ @@ -110,8 +120,11 @@ QT_END_NAMESPACE Q_CLASSINFO("QML.Extended", #EXTENDED_TYPE) \ using QmlExtendedType = EXTENDED_TYPE; \ template<class, class> friend struct QML_PRIVATE_NAMESPACE::QmlExtended; \ + QT_WARNING_PUSH \ + QT_WARNING_DISABLE_GCC("-Wredundant-decls") \ template<typename... Args> \ friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \ + QT_WARNING_POP \ inline constexpr void qt_qmlMarker_extended() {} #define QML_EXTENDED_NAMESPACE(EXTENDED_NAMESPACE) \ @@ -119,8 +132,11 @@ QT_END_NAMESPACE Q_CLASSINFO("QML.ExtensionIsNamespace", "true") \ static constexpr const QMetaObject *qmlExtendedNamespace() { return &EXTENDED_NAMESPACE::staticMetaObject; } \ template<class, class> friend struct QML_PRIVATE_NAMESPACE::QmlExtendedNamespace; \ + QT_WARNING_PUSH \ + QT_WARNING_DISABLE_GCC("-Wredundant-decls") \ template<typename... Args> \ friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \ + QT_WARNING_POP \ inline constexpr void qt_qmlMarker_extendedNamespace() {} #define QML_NAMESPACE_EXTENDED(EXTENDED_NAMESPACE) \ @@ -130,8 +146,11 @@ QT_END_NAMESPACE Q_CLASSINFO("QML.Element", "anonymous") \ enum class QmlIsInterface {yes = true}; \ template<typename, typename> friend struct QML_PRIVATE_NAMESPACE::QmlInterface; \ + QT_WARNING_PUSH \ + QT_WARNING_DISABLE_GCC("-Wredundant-decls") \ template<typename... Args> \ friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \ + QT_WARNING_POP \ inline constexpr void qt_qmlMarker_interface() {} #define QML_IMPLEMENTS_INTERFACES(INTERFACES) \ @@ -144,8 +163,11 @@ QT_END_NAMESPACE using QmlSequenceValueType = VALUE_TYPE; \ enum class QmlIsSequence {yes = true}; \ template<typename, typename> friend struct QML_PRIVATE_NAMESPACE::QmlSequence; \ + QT_WARNING_PUSH \ + QT_WARNING_DISABLE_GCC("-Wredundant-decls") \ template<typename... Args> \ friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \ + QT_WARNING_POP \ inline constexpr void qt_qmlMarker_sequence() {} #define QML_UNAVAILABLE \ @@ -155,8 +177,11 @@ QT_END_NAMESPACE Q_CLASSINFO("QML.Foreign", #FOREIGN_TYPE) \ using QmlForeignType = FOREIGN_TYPE; \ template<class, class> friend struct QML_PRIVATE_NAMESPACE::QmlResolved; \ + QT_WARNING_PUSH \ + QT_WARNING_DISABLE_GCC("-Wredundant-decls") \ template<typename... Args> \ friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \ + QT_WARNING_POP \ inline constexpr void qt_qmlMarker_foreign() {} #define QML_FOREIGN_NAMESPACE(FOREIGN_NAMESPACE) \ |