From 0510591c36591816a6ff3f87a04451001b7ed46f Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 13 Sep 2016 20:41:16 +0200 Subject: [PATCH] build: Use more compiler warnings * configure.ac: Add useful compiler warnings. -- It is strange that this seems to be the only GnuPG package which does not use modern warning. Signed-off-by: Werner Koch --- configure.ac | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/configure.ac b/configure.ac index 744b52a1..bac7908d 100644 --- a/configure.ac +++ b/configure.ac @@ -512,6 +512,35 @@ AM_SUBST_NOTMAKE(API__SSIZE_T) # Checks for compiler features. if test "$GCC" = yes; then CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes" + if test "$USE_MAINTAINER_MODE" = "yes"; then + CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security" + + # If -Wno-missing-field-initializers is supported we can enable a + # a bunch of really useful warnings. + AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers]) + _gcc_cflags_save=$CFLAGS + CFLAGS="-Wno-missing-field-initializers" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no) + AC_MSG_RESULT($_gcc_wopt) + CFLAGS=$_gcc_cflags_save; + if test x"$_gcc_wopt" = xyes ; then + CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast" + CFLAGS="$CFLAGS -Wwrite-strings" + CFLAGS="$CFLAGS -Wdeclaration-after-statement" + CFLAGS="$CFLAGS -Wno-missing-field-initializers" + CFLAGS="$CFLAGS -Wno-sign-compare" + fi + + AC_MSG_CHECKING([if gcc supports -Wpointer-arith]) + _gcc_cflags_save=$CFLAGS + CFLAGS="-Wpointer-arith" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no) + AC_MSG_RESULT($_gcc_wopt) + CFLAGS=$_gcc_cflags_save; + if test x"$_gcc_wopt" = xyes ; then + CFLAGS="$CFLAGS -Wpointer-arith" + fi + fi if test "$have_w32_system" = yes; then CFLAGS="$CFLAGS -mms-bitfields" fi