Skip to content

Commit 6bff03b

Browse files
committed
build: don't error on -Wattributes with GCC <14
We need to annotate `CHDPubKey::nVersion` with `[[maybe_unused]]` to avoid upsetting Clang due to `-Wunused-private-field`. GCC 11 doesn't seem to emit a warning for that variable and therefore, finds the annotation unnecessary, triggering an error due to `-Wattributes`. Since both Clang 18 and GCC 14 agree with the `-Wunused-private-field` assessment, we are better off suppressing `-Wattributes` error-like treatment on lower compiler versions.
1 parent 9aab60b commit 6bff03b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,16 @@ if test "$enable_werror" = "yes"; then
468468
int main(void) { return 0; }
469469
])])
470470

471+
dnl -Wattributes cause problems with some versions of GCC. Do not treat these warnings as errors.
472+
AX_CHECK_COMPILE_FLAG([-Wattributes], [NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-error=attributes"], [], [$CXXFLAG_WERROR], [AC_LANG_SOURCE([
473+
#if defined(__clang__) || defined(__INTEL_COMPILER) || !defined(__GNUC__)
474+
#error Non-GCC compiler detected, not setting flag
475+
#elif defined(__GNUC__) && __GNUC__ >= 14
476+
#error GCC >=14 detected, not setting flag
477+
#endif
478+
int main(void) { return 0; }
479+
])])
480+
471481
dnl -Wstringop-overread and -Wstringop-overflow are broken in gcc
472482
AX_CHECK_COMPILE_FLAG([-Wstringop-overread], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wno-stringop-overread"], [], [$CXXFLAG_WERROR])
473483
AX_CHECK_COMPILE_FLAG([-Wstringop-overflow], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wno-stringop-overflow"], [], [$CXXFLAG_WERROR])

0 commit comments

Comments
 (0)