From f90205951c347763a76681724fe3f7907ce3559b Mon Sep 17 00:00:00 2001 From: ARATA Mizuki Date: Mon, 21 Sep 2015 23:45:51 +0900 Subject: [PATCH 1/3] Add macros to conditionally suppress clang warnings. The added macros wxCLANG_WARNING_{SUPPRESS,RESTORE} are similar to wxGCC_WARNING_{SUPPRESS,RESTORE}, but the `wxCLANG_' version will expand to compiler pragmas only when the warning name is known to the compiler. They use clang's __has_warning feature. --- include/wx/defs.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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. From 450d9ce2b53e5f0ec9225ebab438374b509cfb38 Mon Sep 17 00:00:00 2001 From: ARATA Mizuki Date: Mon, 21 Sep 2015 21:43:30 +0900 Subject: [PATCH 2/3] Suppress clang warning [-Winconsistent-missing-override] for GetClassInfo() in wxDECLARE_ABSTRACT_CLASS. --- include/wx/rtti.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); \ From d399d544f1bae126c7cedb22a15c330ae27cdd82 Mon Sep 17 00:00:00 2001 From: ARATA Mizuki Date: Mon, 21 Sep 2015 23:41:56 +0900 Subject: [PATCH 3/3] Suppress clang warning [-Winconsistent-missing-override] in DECLARE_HELP_PROVISION(). --- include/wx/richtext/richtextuicustomization.h | 2 ++ 1 file changed, 2 insertions(+) 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: \