Fix Clang warning about inconsistent use of C++11 override
We cannot use override in the Q_OBJECT macro, so tell Clang not to warn about our lack of use of the keyword in the three virtuals that Q_OBJECT overrides when the user uses Q_DECL_OVERRIDE in their own functions. We can't use Q_DECL_OVERRIDE for two reasons: 1) because that would trigger the warning in any and all virtual overrides the user may have in their own class (and most of Qt) 2) because when Q_OBJECT is used in QObject, it's not overriding anything -- it's the base declaration For #2, we could add a different macro exclusively for QObject that moc would expand, but it's unnecessary work. Change-Id: Ic9cb7896f93f06f4e86b6a42dc08f96d257f7550 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
2e4b1a8334
commit
3092bd56c3
@ -138,15 +138,24 @@ inline void qYouForgotTheQ_OBJECT_Macro(T1, T2) {}
|
||||
# define Q_DECL_HIDDEN_STATIC_METACALL Q_DECL_HIDDEN
|
||||
#endif
|
||||
|
||||
#if defined(Q_CC_CLANG) && Q_CC_CLANG >= 306
|
||||
# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_CLANG("-Winconsistent-missing-override")
|
||||
#else
|
||||
# define Q_OBJECT_NO_OVERRIDE_WARNING
|
||||
#endif
|
||||
|
||||
/* qmake ignore Q_OBJECT */
|
||||
#define Q_OBJECT \
|
||||
public: \
|
||||
Q_OBJECT_CHECK \
|
||||
QT_WARNING_PUSH \
|
||||
Q_OBJECT_NO_OVERRIDE_WARNING \
|
||||
static const QMetaObject staticMetaObject; \
|
||||
virtual const QMetaObject *metaObject() const; \
|
||||
virtual void *qt_metacast(const char *); \
|
||||
QT_TR_FUNCTIONS \
|
||||
virtual int qt_metacall(QMetaObject::Call, int, void **); \
|
||||
QT_WARNING_POP \
|
||||
QT_TR_FUNCTIONS \
|
||||
private: \
|
||||
Q_DECL_HIDDEN_STATIC_METACALL static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); \
|
||||
struct QPrivateSignal {};
|
||||
|
Loading…
Reference in New Issue
Block a user