Suppress -Wsuggest-override warnings in user code for gcc too

This was already done for clang -Winconsistent-missing-override, but
gcc has a similar warning since 5.1 and, moreover, latest versions of
clang support this gcc warning as well, so add a special macro which
handles both compilers and use it in all wx macros defining virtual
functions instead of just disabling one of the clang warnings.

Closes https://github.com/wxWidgets/wxWidgets/pull/2000
This commit is contained in:
Teodor Petrov
2020-07-27 00:00:35 +03:00
committed by Vadim Zeitlin
parent 19db07d668
commit c924ecb10a
4 changed files with 29 additions and 7 deletions

View File

@@ -708,6 +708,28 @@ typedef short int WXTYPE;
# define wxCLANG_WARNING_RESTORE(x)
#endif
/*
Specific macro for disabling warnings related to not using override: this
has to be done differently for gcc and clang and is only supported since
gcc 5.1.
*/
#if defined(__clang__)
# define wxWARNING_SUPPRESS_MISSING_OVERRIDE() \
wxCLANG_WARNING_SUPPRESS(suggest-override) \
wxCLANG_WARNING_SUPPRESS(inconsistent-missing-override)
# define wxWARNING_RESTORE_MISSING_OVERRIDE() \
wxCLANG_WARNING_RESTORE(inconsistent-missing-override) \
wxCLANG_WARNING_RESTORE(suggest-override)
#elif wxCHECK_GCC_VERSION(5, 1)
# define wxWARNING_SUPPRESS_MISSING_OVERRIDE() \
wxGCC_WARNING_SUPPRESS(suggest-override)
# define wxWARNING_RESTORE_MISSING_OVERRIDE() \
wxGCC_WARNING_RESTORE(suggest-override)
#else
# define wxWARNING_SUPPRESS_MISSING_OVERRIDE()
# define wxWARNING_RESTORE_MISSING_OVERRIDE()
#endif
/*
Combination of the two variants above: should be used for deprecated
functions which are defined inline and are used by wxWidgets itself.