Fix clang warnings about inconsistent missing "override" keyword

Add wxCLANG_WARNING_SUPPRESS() and wxCLANG_WARNING_RESTORE() and use them to
suppress -Winconsistent-missing-override warnings.

Closes https://github.com/wxWidgets/wxWidgets/pull/99
This commit is contained in:
Vadim Zeitlin 2015-11-08 19:11:53 +01:00
commit 79f62505bb
3 changed files with 28 additions and 1 deletions

View File

@ -695,6 +695,29 @@ typedef short int WXTYPE;
# define wxGCC_WARNING_RESTORE(x)
#endif
/*
Macros to suppress and restore clang warning only when it is valid.
Example:
wxCLANG_WARNING_SUPPRESS(inconsistent-missing-override)
virtual wxClassInfo *GetClassInfo() const
wxCLANG_WARNING_RESTORE(inconsistent-missing-override)
*/
#if defined(__has_warning)
# define wxCLANG_HAS_WARNING(x) __has_warning(x) /* allow macro expansion for the warning name */
# define wxCLANG_IF_VALID_WARNING(x,y) \
wxCONCAT(wxCLANG_IF_VALID_WARNING_,wxCLANG_HAS_WARNING(wxSTRINGIZE(wxCONCAT(-W,x))))(y)
# define wxCLANG_IF_VALID_WARNING_0(x)
# define wxCLANG_IF_VALID_WARNING_1(x) x
# define wxCLANG_WARNING_SUPPRESS(x) \
wxCLANG_IF_VALID_WARNING(x,wxGCC_WARNING_SUPPRESS(x))
# define wxCLANG_WARNING_RESTORE(x) \
wxCLANG_IF_VALID_WARNING(x,wxGCC_WARNING_RESTORE(x))
#else
# define wxCLANG_WARNING_SUPPRESS(x)
# define wxCLANG_WARNING_RESTORE(x)
#endif
/*
Combination of the two variants above: should be used for deprecated
functions which are defined inline and are used by wxWidgets itself.

View File

@ -103,11 +103,13 @@ protected:
/// of the formatting dialog.
#define DECLARE_HELP_PROVISION() \
wxCLANG_WARNING_SUPPRESS(inconsistent-missing-override) \
virtual long GetHelpId() const { return sm_helpInfo.GetHelpId(); } \
virtual void SetHelpId(long id) { sm_helpInfo.SetHelpId(id); } \
virtual wxRichTextUICustomization* GetUICustomization() const { return sm_helpInfo.GetUICustomization(); } \
virtual void SetUICustomization(wxRichTextUICustomization* customization) { sm_helpInfo.SetUICustomization(customization); } \
virtual bool ShowHelp(wxWindow* win) { return sm_helpInfo.ShowHelp(win); } \
wxCLANG_WARNING_RESTORE(inconsistent-missing-override) \
public: \
static wxRichTextHelpInfo& GetHelpInfo() { return sm_helpInfo; }\
protected: \

View File

@ -128,7 +128,9 @@ WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name);
#define wxDECLARE_ABSTRACT_CLASS(name) \
public: \
static wxClassInfo ms_classInfo; \
virtual wxClassInfo *GetClassInfo() const
wxCLANG_WARNING_SUPPRESS(inconsistent-missing-override) \
virtual wxClassInfo *GetClassInfo() const \
wxCLANG_WARNING_RESTORE(inconsistent-missing-override)
#define wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(name) \
wxDECLARE_NO_ASSIGN_CLASS(name); \