diff --git a/include/wx/defs.h b/include/wx/defs.h index 962def7d5b..ceba1f7d40 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -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. diff --git a/include/wx/richtext/richtextuicustomization.h b/include/wx/richtext/richtextuicustomization.h index 92c42d7b1f..d9fadfc808 100644 --- a/include/wx/richtext/richtextuicustomization.h +++ b/include/wx/richtext/richtextuicustomization.h @@ -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: \ diff --git a/include/wx/rtti.h b/include/wx/rtti.h index 51017baa2f..308b65767b 100644 --- a/include/wx/rtti.h +++ b/include/wx/rtti.h @@ -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); \