summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-02-14 11:29:20 +0100
committerJim Meyering <meyering@redhat.com>2009-03-02 09:10:26 +0100
commit6449370e9e07939712bbe0ebfad38ad78ab69097 (patch)
tree7f6329d520c14db7cc438c33c9839a4ac4cc2bb9
parentebfbdf9f0e53d5eb8e6a1c85d825a1a9f0f1baef (diff)
downloadcoreutils-6449370e9e07939712bbe0ebfad38ad78ab69097.tar.xz
maint: enable many gcc warnings
* bootstrap.conf (gnulib_modules): Add manywarnings. * configure.ac: Use gl_MANYWARN_ALL_GCC, and exclude options I don't want or that provoke too many warnings. (WARN_CFLAGS, WERROR_CFLAGS): Define. (lint, GNULIB_PORTCHECK): Define. (_FORTIFY_SOURCE): Define to 2.
-rw-r--r--bootstrap.conf1
-rw-r--r--configure.ac57
2 files changed, 44 insertions, 14 deletions
diff --git a/bootstrap.conf b/bootstrap.conf
index 89564fe29..9c385e46d 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -67,6 +67,7 @@ gnulib_modules="
inttostr inttypes isapipe
lchmod lchown lib-ignore linebuffer link-follow
long-options lstat malloc
+ manywarnings
mbrtowc
mbswidth
memcasecmp mempcpy
diff --git a/configure.ac b/configure.ac
index 99452c82a..f10191fa8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
# -*- autoconf -*-
# Process this file with autoconf to produce a configure script.
-# Copyright (C) 1991, 1993-2008 Free Software Foundation, Inc.
+# Copyright (C) 1991, 1993-2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -58,23 +58,52 @@ AC_ARG_ENABLE([gcc-warnings],
if test "$gl_gcc_warnings" = yes; then
gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
AC_SUBST([WERROR_CFLAGS])
- gl_WARN_ADD([-Wall])
- gl_WARN_ADD([-Wextra])
- gl_WARN_ADD([-Wshadow])
- gl_WARN_ADD([-Wno-sign-compare])
- gl_WARN_ADD([-Wformat])
- gl_WARN_ADD([-Wformat-security])
- gl_WARN_ADD([-Wcast-align])
- gl_WARN_ADD([-Wpointer-arith])
- gl_WARN_ADD([-Wwrite-strings])
- gl_WARN_ADD([-Wbad-function-cast])
- gl_WARN_ADD([-Wmissing-declarations])
- gl_WARN_ADD([-Wmissing-prototypes])
- gl_WARN_ADD([-Wstrict-prototypes])
+
+ # Add many warnings, except some...
+ nw="$nw -Wdeclaration-after-statement" # too useful to forbid
+ nw="$nw -Waggregate-return" # anachronistic
+ 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
+ # 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
+ # ?? -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
+ gl_WARN_ADD([-fdiagnostics-show-option])
+
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])
fi
AC_FUNC_FORK