Skip to content

Commit e6211d8

Browse files
committed
build: Enable -Wsuggest-override
1 parent de5e91c commit e6211d8

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

configure.ac

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,24 @@ if test x$use_sanitizers != x; then
355355
]],[[]])])
356356
fi
357357

358+
dnl GCC<9.2 reports a redundant -Wsuggest-override warning on a 'final' method.
359+
dnl See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010
360+
AC_MSG_CHECKING(for GCC version < 9.2)
361+
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
362+
#if !defined(__clang__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 902)
363+
#error GCC<9.2 has the bug 78010
364+
#endif
365+
]])],
366+
[
367+
AC_MSG_RESULT(no)
368+
have_gcc_suggest_override_bug=no
369+
],
370+
[
371+
AC_MSG_RESULT(yes)
372+
AC_MSG_WARN([GCC<9.2 reports a redundant -Wsuggest-override warning on a 'final' method, disabling -Wsuggest-override.])
373+
have_gcc_suggest_override_bug=yes
374+
])
375+
358376
ERROR_CXXFLAGS=
359377
if test "x$enable_werror" = "xyes"; then
360378
if test "x$CXXFLAG_WERROR" = "x"; then
@@ -368,6 +386,9 @@ if test "x$enable_werror" = "xyes"; then
368386
AX_CHECK_COMPILE_FLAG([-Werror=return-type],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"],,[[$CXXFLAG_WERROR]])
369387
AX_CHECK_COMPILE_FLAG([-Werror=conditional-uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=conditional-uninitialized"],,[[$CXXFLAG_WERROR]])
370388
AX_CHECK_COMPILE_FLAG([-Werror=sign-compare],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=sign-compare"],,[[$CXXFLAG_WERROR]])
389+
if test "x$have_gcc_suggest_override_bug" = "xno"; then
390+
AX_CHECK_COMPILE_FLAG([-Werror=suggest-override],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=suggest-override"],,[[$CXXFLAG_WERROR]])
391+
fi
371392
fi
372393

373394
if test "x$CXXFLAGS_overridden" = "xno"; then
@@ -385,6 +406,9 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
385406
AX_CHECK_COMPILE_FLAG([-Wdate-time],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdate-time"],,[[$CXXFLAG_WERROR]])
386407
AX_CHECK_COMPILE_FLAG([-Wconditional-uninitialized],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wconditional-uninitialized"],,[[$CXXFLAG_WERROR]])
387408
AX_CHECK_COMPILE_FLAG([-Wsign-compare],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsign-compare"],,[[$CXXFLAG_WERROR]])
409+
if test "x$have_gcc_suggest_override_bug" = "xno"; then
410+
AX_CHECK_COMPILE_FLAG([-Wsuggest-override],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"],,[[$CXXFLAG_WERROR]])
411+
fi
388412

389413
dnl Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
390414
dnl unknown options if any other warning is produced. Test the -Wfoo case, and

src/Makefile.leveldb.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ LEVELDB_CPPFLAGS_INT += -DLEVELDB_PLATFORM_POSIX
3636
endif
3737

3838
leveldb_libleveldb_a_CPPFLAGS = $(AM_CPPFLAGS) $(LEVELDB_CPPFLAGS_INT) $(LEVELDB_CPPFLAGS)
39-
leveldb_libleveldb_a_CXXFLAGS = $(filter-out -Wconditional-uninitialized -Werror=conditional-uninitialized, $(AM_CXXFLAGS)) $(PIE_FLAGS)
39+
leveldb_libleveldb_a_CXXFLAGS = $(filter-out -Wconditional-uninitialized -Werror=conditional-uninitialized -Wsuggest-override -Werror=suggest-override, $(AM_CXXFLAGS)) $(PIE_FLAGS)
4040

4141
leveldb_libleveldb_a_SOURCES=
4242
leveldb_libleveldb_a_SOURCES += leveldb/port/port_stdcxx.h

src/wallet/db.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@
1919
#include <unordered_map>
2020
#include <vector>
2121

22+
#if defined(__GNUC__) && !defined(__clang__)
23+
#pragma GCC diagnostic push
24+
#pragma GCC diagnostic ignored "-Wsuggest-override"
25+
#endif
2226
#include <db_cxx.h>
27+
#if defined(__GNUC__) && !defined(__clang__)
28+
#pragma GCC diagnostic pop
29+
#endif
2330

2431
struct bilingual_str;
2532

0 commit comments

Comments
 (0)