Build: Make configure add more warning flags for GCC and Clang.

-Wstrict-aliasing was removed from the list since it is enabled
by -Wall already.

A normal build is clean with these on GNU/Linux x86-64 with
GCC 12.2.0 and Clang 14.0.6.
This commit is contained in:
Lasse Collin 2023-01-12 04:17:24 +02:00 committed by Jia Tan
parent c47ecd6d39
commit b16b9c0d22
1 changed files with 31 additions and 5 deletions

View File

@ -1029,26 +1029,35 @@ if test "$GCC" = yes ; then
# backed up with "return LZMA_PROG_ERROR". # backed up with "return LZMA_PROG_ERROR".
# * -Wcast-qual would break various things where we need a non-const # * -Wcast-qual would break various things where we need a non-const
# pointer although we don't modify anything through it. # pointer although we don't modify anything through it.
# * -Wcast-align breaks optimized CRC32 and CRC64 implementation
# on some architectures (not on x86), where this warning is bogus,
# because we take care of correct alignment.
# * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations # * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations
# don't seem so useful here; at least the last one gives some # don't seem so useful here; at least the last one gives some
# warnings which are not bugs. # warnings which are not bugs.
# * -Wconversion still shows too many warnings.
#
# The flags before the empty line are for GCC and many of them
# are supported by Clang too. The flags after the empty line are
# for Clang.
for NEW_FLAG in \ for NEW_FLAG in \
-Wall \ -Wall \
-Wextra \ -Wextra \
-Wvla \ -Wvla \
-Wc99-c11-compat \
-Wformat=2 \ -Wformat=2 \
-Winit-self \ -Winit-self \
-Wmissing-include-dirs \ -Wmissing-include-dirs \
-Wstrict-aliasing \ -Wshift-overflow=2 \
-Wstrict-overflow=3 \
-Walloc-zero \
-Wduplicated-cond \
-Wfloat-equal \ -Wfloat-equal \
-Wundef \ -Wundef \
-Wshadow \ -Wshadow \
-Wpointer-arith \ -Wpointer-arith \
-Wbad-function-cast \ -Wbad-function-cast \
-Wwrite-strings \ -Wwrite-strings \
-Wdate-time \
-Wsign-conversion \
-Wfloat-conversion \
-Wlogical-op \ -Wlogical-op \
-Waggregate-return \ -Waggregate-return \
-Wstrict-prototypes \ -Wstrict-prototypes \
@ -1056,7 +1065,24 @@ if test "$GCC" = yes ; then
-Wmissing-prototypes \ -Wmissing-prototypes \
-Wmissing-declarations \ -Wmissing-declarations \
-Wmissing-noreturn \ -Wmissing-noreturn \
-Wredundant-decls -Wredundant-decls \
\
-Wc99-compat \
-Wc11-extensions \
-Wc2x-compat \
-Wc2x-extensions \
-Wpre-c2x-compat \
-Warray-bounds-pointer-arithmetic \
-Wassign-enum \
-Wconditional-uninitialized \
-Wdocumentation \
-Wduplicate-enum \
-Wempty-translation-unit \
-Wflexible-array-extensions \
-Wmissing-variable-declarations \
-Wnewline-eof \
-Wshift-sign-overflow \
-Wstring-conversion
do do
AC_MSG_CHECKING([if $CC accepts $NEW_FLAG]) AC_MSG_CHECKING([if $CC accepts $NEW_FLAG])
OLD_CFLAGS="$CFLAGS" OLD_CFLAGS="$CFLAGS"