Work around -Wuggest-override for event table macros from gcc 11
Disabling -Wsuggest-override inside macros is broken in gcc, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578, and has started affecting wxWARNING_SUPPRESS_MISSING_OVERRIDE since gcc 11, i.e. this macro doesn't have any effect any more and the warning is still given. Avoid it by actually specifying "override" for gcc 11 (as doing it for all compilers would result in -Winconsistent-missing-override from clang) and check that we don't get this warning in the allheaders test. Also don't use wxDECLARE_ABSTRACT_CLASS() inside wxObject itself, now that it uses "override", which is not appropriate for the base class version. This is arguably more clear and should have been done like this since the beginning anyhow.
This commit is contained in:
@@ -740,6 +740,17 @@ typedef short int WXTYPE;
|
|||||||
# define wxWARNING_RESTORE_MISSING_OVERRIDE()
|
# define wxWARNING_RESTORE_MISSING_OVERRIDE()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
Macros above don't work with gcc 11 due to a compiler bug, unless we also
|
||||||
|
use "override" in the function declaration -- but this breaks other
|
||||||
|
compilers, so define a specific macro for gcc 11 only.
|
||||||
|
*/
|
||||||
|
#if wxCHECK_GCC_VERSION(11, 0)
|
||||||
|
# define wxDUMMY_OVERRIDE wxOVERRIDE
|
||||||
|
#else
|
||||||
|
# define wxDUMMY_OVERRIDE
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Combination of the two variants above: should be used for deprecated
|
Combination of the two variants above: should be used for deprecated
|
||||||
functions which are defined inline and are used by wxWidgets itself.
|
functions which are defined inline and are used by wxWidgets itself.
|
||||||
|
@@ -4322,8 +4322,8 @@ typedef void (wxEvtHandler::*wxPressAndTapEventFunction)(wxPressAndTapEvent&);
|
|||||||
static const wxEventTableEntry sm_eventTableEntries[]; \
|
static const wxEventTableEntry sm_eventTableEntries[]; \
|
||||||
protected: \
|
protected: \
|
||||||
wxWARNING_SUPPRESS_MISSING_OVERRIDE() \
|
wxWARNING_SUPPRESS_MISSING_OVERRIDE() \
|
||||||
const wxEventTable* GetEventTable() const; \
|
const wxEventTable* GetEventTable() const wxDUMMY_OVERRIDE; \
|
||||||
wxEventHashTable& GetEventHashTable() const; \
|
wxEventHashTable& GetEventHashTable() const wxDUMMY_OVERRIDE; \
|
||||||
wxWARNING_RESTORE_MISSING_OVERRIDE() \
|
wxWARNING_RESTORE_MISSING_OVERRIDE() \
|
||||||
static const wxEventTable sm_eventTable; \
|
static const wxEventTable sm_eventTable; \
|
||||||
static wxEventHashTable sm_eventHashTable
|
static wxEventHashTable sm_eventHashTable
|
||||||
|
@@ -368,8 +368,6 @@ private:
|
|||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxObject
|
class WXDLLIMPEXP_BASE wxObject
|
||||||
{
|
{
|
||||||
wxDECLARE_ABSTRACT_CLASS(wxObject);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxObject() { m_refData = NULL; }
|
wxObject() { m_refData = NULL; }
|
||||||
virtual ~wxObject() { UnRef(); }
|
virtual ~wxObject() { UnRef(); }
|
||||||
@@ -392,6 +390,7 @@ public:
|
|||||||
|
|
||||||
bool IsKindOf(const wxClassInfo *info) const;
|
bool IsKindOf(const wxClassInfo *info) const;
|
||||||
|
|
||||||
|
virtual wxClassInfo *GetClassInfo() const;
|
||||||
|
|
||||||
// Turn on the correct set of new and delete operators
|
// Turn on the correct set of new and delete operators
|
||||||
|
|
||||||
@@ -453,6 +452,8 @@ protected:
|
|||||||
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||||
|
|
||||||
wxObjectRefData *m_refData;
|
wxObjectRefData *m_refData;
|
||||||
|
|
||||||
|
static wxClassInfo ms_classInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline wxObject *wxCheckDynamicCast(wxObject *obj, wxClassInfo *classInfo)
|
inline wxObject *wxCheckDynamicCast(wxObject *obj, wxClassInfo *classInfo)
|
||||||
|
@@ -140,7 +140,7 @@ WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name);
|
|||||||
#define wxDECLARE_ABSTRACT_CLASS(name) \
|
#define wxDECLARE_ABSTRACT_CLASS(name) \
|
||||||
public: \
|
public: \
|
||||||
wxWARNING_SUPPRESS_MISSING_OVERRIDE() \
|
wxWARNING_SUPPRESS_MISSING_OVERRIDE() \
|
||||||
virtual wxClassInfo *GetClassInfo() const; \
|
virtual wxClassInfo *GetClassInfo() const wxDUMMY_OVERRIDE; \
|
||||||
wxWARNING_RESTORE_MISSING_OVERRIDE() \
|
wxWARNING_RESTORE_MISSING_OVERRIDE() \
|
||||||
static wxClassInfo ms_classInfo
|
static wxClassInfo ms_classInfo
|
||||||
|
|
||||||
|
@@ -387,6 +387,33 @@
|
|||||||
|
|
||||||
#include "allheaders.h"
|
#include "allheaders.h"
|
||||||
|
|
||||||
|
// Check that using wx macros doesn't result in -Wsuggest-override or
|
||||||
|
// equivalent warnings in classes using and not using "override".
|
||||||
|
struct Base : wxEvtHandler
|
||||||
|
{
|
||||||
|
virtual ~Base() { }
|
||||||
|
|
||||||
|
virtual void Foo() { }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DerivedWithoutOverride : Base
|
||||||
|
{
|
||||||
|
void OnIdle(wxIdleEvent&) { }
|
||||||
|
|
||||||
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(DerivedWithoutOverride);
|
||||||
|
wxDECLARE_EVENT_TABLE();
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DerivedWithOverride : Base
|
||||||
|
{
|
||||||
|
virtual void Foo() wxOVERRIDE { }
|
||||||
|
|
||||||
|
void OnIdle(wxIdleEvent&) { }
|
||||||
|
|
||||||
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY(DerivedWithOverride);
|
||||||
|
wxDECLARE_EVENT_TABLE();
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef GCC_TURN_OFF
|
#ifdef GCC_TURN_OFF
|
||||||
// Just using REQUIRE() below triggers -Wparentheses, so avoid it.
|
// Just using REQUIRE() below triggers -Wparentheses, so avoid it.
|
||||||
GCC_TURN_OFF(parentheses)
|
GCC_TURN_OFF(parentheses)
|
||||||
|
Reference in New Issue
Block a user