)
AC_ARG_ENABLE([gcc-warnings],
- [AS_HELP_STRING([--enable-gcc-warnings],
- [turn on many GCC warnings (for developers; best with GNU make)])],
+ [AS_HELP_STRING([--enable-gcc-warnings@<:@=TYPE@:>@],
+ [control generation of GCC warnings. The TYPE 'no' disables
+ warnings (default for non-developer builds); 'yes' generates
+ cheap warnings if available (default for developer builds);
+ 'expensive' in addition generates expensive-to-compute warnings
+ if available.])],
[case $enableval in
- yes|no) ;;
+ no|yes|expensive) ;;
*) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
esac
gl_gcc_warnings=$enableval],
&& gl_gcc_warnings=yes])]
)
-if test "$gl_gcc_warnings" = yes; then
+if test $gl_gcc_warnings != no; then
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
AC_SUBST([WERROR_CFLAGS])
- nw=
+ ew=
+ AS_IF([test $gl_gcc_warnings != expensive],
+ [# -fanalyzer and related options slow GCC considerably.
+ ew="$ew -fanalyzer -Wno-analyzer-double-free -Wno-analyzer-malloc-leak"
+ ew="$ew -Wno-analyzer-null-dereference -Wno-analyzer-use-after-free"])
+
# This, $nw, is the list of warnings we disable.
+ nw=$ew
nw="$nw -Wdeclaration-after-statement" # too useful to forbid
nw="$nw -Waggregate-return" # anachronistic
nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
# We use a slightly smaller set of warning options for lib/.
# Remove the following and save the result in GNULIB_WARN_CFLAGS.
- nw=
+ nw=$ew
nw="$nw -Wduplicated-branches" # Too many false alarms
nw="$nw -Wformat-truncation=2"
nw="$nw -Wstrict-overflow"