[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/10] build: enable many warnings
From: |
Jim Meyering |
Subject: |
[PATCH 04/10] build: enable many warnings |
Date: |
Fri, 20 Nov 2009 21:06:15 +0100 |
From: Jim Meyering <address@hidden>
* configure.ac: Add support for --enable-gcc-warnings.
* bootstrap.conf (gnulib_modules): Add manywarnings.
* Makefile.am (AM_CFLAGS): Add (WARN_CFLAGS) # $(WERROR_CFLAGS)
---
Makefile.am | 1 +
bootstrap.conf | 1 +
configure.ac | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
m4/.gitignore | 2 +
4 files changed, 88 insertions(+), 0 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 59cc615..406e344 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,7 @@
SUBDIRS = lib doc
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = -I$(top_srcdir)/lib
+AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
man_MANS = gunzip.1 gzexe.1 gzip.1 \
zcat.1 zcmp.1 zdiff.1 zforce.1 zgrep.1 zless.1 zmore.1 znew.1
diff --git a/bootstrap.conf b/bootstrap.conf
index 5f1e653..913deab 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -40,6 +40,7 @@ gnumakefile
lstat
maintainer-makefile
malloc
+manywarnings
perror
printf-posix
realloc
diff --git a/configure.ac b/configure.ac
index c568c02..7ae9863 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,6 +43,90 @@ AC_SYS_LARGEFILE
gl_INIT
+AC_ARG_ENABLE([gcc-warnings],
+ [AS_HELP_STRING([--enable-gcc-warnings],
+ [turn on lots of GCC warnings (for developers)])],
+ [case $enableval in
+ yes|no) ;;
+ *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
+ esac
+ gl_gcc_warnings=$enableval],
+ [gl_gcc_warnings=no]
+)
+
+if test "$gl_gcc_warnings" = yes; then
+ gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
+ AC_SUBST([WERROR_CFLAGS])
+
+ nw=
+ # This, $nw, is the list of warnings we disable.
+ nw="$nw -Wdeclaration-after-statement" # too useful to forbid
+ nw="$nw -Waggregate-return" # anachronistic
+ nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
+ nw="$nw -Wc++-compat" # We don't care about C++ compilers
+ nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
+ nw="$nw -Wtraditional" # Warns on #elif which we use often
+ nw="$nw -Wcast-qual" # Too many warnings for now
+ nw="$nw -Wconversion" # Too many warnings for now
+ nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
+ nw="$nw -Wsign-conversion" # Too many warnings for now
+ nw="$nw -Wtraditional-conversion" # Too many warnings for now
+ nw="$nw -Wunreachable-code" # Too many warnings for now
+ nw="$nw -Wpadded" # Our structs are not padded
+ nw="$nw -Wredundant-decls" # openat.h declares e.g., mkdirat
+ nw="$nw -Wlogical-op" # any use of fwrite provokes this
+ nw="$nw -Wformat-nonliteral" # who.c and pinky.c strftime uses
+ nw="$nw -Wvla" # warnings in gettext.h
+ nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
+ nw="$nw -Wswitch-enum" # Too many warnings for now
+ nw="$nw -Wswitch-default" # Too many warnings for now
+ nw="$nw -Wstack-protector" # not worth working around
+ # things I might fix soon:
+ nw="$nw -Wfloat-equal" # sort.c, seq.c
+ nw="$nw -Wmissing-format-attribute" # copy.c
+ nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
+ nw="$nw -Winline" # system.h's
readdir_ignoring_dot_and_dotdot
+ nw="$nw -Wstrict-overflow" # expr.c, pr.c, tr.c, factor.c
+ # initial problems in gzip
+ nw="$nw -Wold-style-definition"
+ nw="$nw -Wshadow"
+ # ?? -Wstrict-overflow
+
+ gl_MANYWARN_ALL_GCC([ws])
+ gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
+ for w in $ws; do
+ gl_WARN_ADD([$w])
+ done
+ gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
+ gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
+ gl_WARN_ADD([-Wno-pointer-sign]) # Too many warnings for now
+ gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
+
+ # In spite of excluding -Wlogical-op above, it is enabled, as of
+ # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
+ gl_WARN_ADD([-Wno-logical-op])
+
+ gl_WARN_ADD([-fdiagnostics-show-option])
+ gl_WARN_ADD([-funit-at-a-time])
+
+ AC_SUBST([WARN_CFLAGS])
+
+ AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
+ AC_DEFINE([_FORTIFY_SOURCE], [2],
+ [enable compile-time and run-time bounds-checking, and some warnings])
+ AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
+
+ # We use a slightly smaller set of warning options for lib/.
+ # Remove the following and save the result in GNULIB_WARN_CFLAGS.
+ nw=
+ nw="$nw -Wuninitialized"
+ nw="$nw -Wunused-macros"
+ nw="$nw -Wmissing-prototypes"
+ nw="$nw -Wold-style-definition"
+ gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
+ AC_SUBST([GNULIB_WARN_CFLAGS])
+fi
+
# cc -E produces incorrect asm files on SVR4, so postprocess it.
ASCPPPOST="sed '/^ *#/d; s,//.*,,; s/% /%/g; s/\\. /./g'"
AC_SUBST([ASCPPPOST])
diff --git a/m4/.gitignore b/m4/.gitignore
index 84d782c..765c33e 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -57,6 +57,7 @@ longlong.m4
lseek.m4
lstat.m4
malloc.m4
+manywarnings.m4
math_h.m4
mbrtowc.m4
mbsinit.m4
@@ -98,6 +99,7 @@ utimens.m4
utimes.m4
vasnprintf.m4
vfprintf-posix.m4
+warnings.m4
wchar.m4
wchar_t.m4
wctype.m4
--
1.6.5.3.433.g11067
- [PATCH 01/10] build: "make stable" emitted an invalid gnupload command, Jim Meyering, 2009/11/20
- [PATCH 09/10] build: avoid warnings about unused macros, Jim Meyering, 2009/11/20
- [PATCH 02/10] maint: cfg.mk: remove factored-out ftp host/dir definitions, Jim Meyering, 2009/11/20
- [PATCH 08/10] build: util.c: avoid warnings about add_envopt, Jim Meyering, 2009/11/20
- [PATCH 05/10] build: use gnulib's fdopendir module, Jim Meyering, 2009/11/20
- [PATCH 03/10] maint: tweak formatting of bootstrap.conf, Jim Meyering, 2009/11/20
- [PATCH 04/10] build: enable many warnings,
Jim Meyering <=
- [PATCH 06/10] build: avoid warnings from -Wstrict-prototypes, Jim Meyering, 2009/11/20
- [PATCH 07/10] build: avoid many const-related warnings, Jim Meyering, 2009/11/20
- [PATCH 10/10] build: unlzw.c: avoid warnings about unused macros, Jim Meyering, 2009/11/20