emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r107961: configure: new option --enab


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107961: configure: new option --enable-gcc-warnings (Bug#11207)
Date: Wed, 18 Apr 2012 10:07:27 -0700
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107961 [merge]
fixes bug(s): http://debbugs.gnu.org/11207
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Wed 2012-04-18 10:07:27 -0700
message:
  configure: new option --enable-gcc-warnings (Bug#11207)
  
  I have been using this change for many months in my private copy
  of Emacs, and have used it to find several bugs.  It's mature
  enough to publish now.
  * Makefile.in (GNULIB_MODULES): Add warnings, manywarnings.
  * configure.in: Support --enable-gcc-warnings, in the style of
  other GNU packages such as coreutils.
  (C_WARNINGS_SWITCH): Remove, replacing with...
  (WARN_CFLAGS, GNULIB_WARN_CFLAGS): New variable.
  (PKG_CHECK_MODULES, C_SWITCH_X_SITE): Use -isystem rather than -I,
  when including system files with GCC.
  * etc/NEWS: Mention --enable-gcc-warnings.
  * INSTALL (DETAILED BUILDING AND INSTALLATION): Likewise.
  * lib/Makefile.am (AM_CFLAGS): New macro.
  * m4/manywarnings.m4, m4/warnings.m4: New files, from gnulib.
  * lib-src/Makefile.in (C_WARNINGS_SWITCH): Remove.
  (WARN_CFLAGS, WERROR_CFLAGS): New macros.
  (BASE_CFLAGS): Use new macros rather than old.
  * lwlib/Makefile.in (C_WARNINGS_SWITCH): Remove.
  (WARN_CFLAGS, WERROR_CFLAGS): New macros.
  (ALL_CFLAGS): Use new macros rather than old.
  * msdos/sed1v2.inp, msdos/sed3v2.inp, msdos/sedlibmk.inp:
  GNULIB_WARN_CFLAGS, WARN_CFLAGS, and WERROR_CFLAGS replace C_WARNINGS_SWITCH.
  * oldXMenu/Makefile.in (C_WARNINGS_SWITCH): Remove.
  (WARN_CFLAGS, WERROR_CFLAGS): New macros.
  (ALL_CFLAGS): Use new macros rather than old.
  * src/Makefile.in (C_WARNINGS_SWITCH): Remove.
  (WARN_CFLAGS, WERROR_CFLAGS): New macros.
  (ALL_CFLAGS): Use new macros rather than old.
  * src/process.c: Ignore -Wstrict-overflow to work around GCC bug 52904.
  * src/regex.c: Ignore -Wstrict-overflow.  If !emacs, also ignore
  -Wunused-but-set-variable, -Wunused-function, -Wunused-macros,
  -Wunused-result, -Wunused-variable.  This should go away once
  the Emacs and Gnulib regex code is merged.
  (xmalloc, xrealloc): Now static.
added:
  m4/manywarnings.m4
  m4/warnings.m4
modified:
  ChangeLog
  INSTALL
  Makefile.in
  configure.in
  etc/NEWS
  lib-src/ChangeLog
  lib-src/Makefile.in
  lib/Makefile.am
  lwlib/ChangeLog
  lwlib/Makefile.in
  msdos/ChangeLog
  msdos/sed1v2.inp
  msdos/sed3v2.inp
  msdos/sedlibmk.inp
  oldXMenu/ChangeLog
  oldXMenu/Makefile.in
  src/ChangeLog
  src/Makefile.in
  src/process.c
  src/regex.c
=== modified file 'ChangeLog'
--- a/ChangeLog 2012-04-17 01:29:58 +0000
+++ b/ChangeLog 2012-04-18 16:45:13 +0000
@@ -1,3 +1,21 @@
+2012-04-18  Paul Eggert  <address@hidden>
+
+       configure: new option --enable-gcc-warnings (Bug#11207)
+       I have been using this change for many months in my private copy
+       of Emacs, and have used it to find several bugs.  It's mature
+       enough to publish now.
+       * Makefile.in (GNULIB_MODULES): Add warnings, manywarnings.
+       * configure.in: Support --enable-gcc-warnings, in the style of
+       other GNU packages such as coreutils.
+       (C_WARNINGS_SWITCH): Remove, replacing with...
+       (WARN_CFLAGS, GNULIB_WARN_CFLAGS): New variable.
+       (PKG_CHECK_MODULES, C_SWITCH_X_SITE): Use -isystem rather than -I,
+       when including system files with GCC.
+       * etc/NEWS: Mention --enable-gcc-warnings.
+       * INSTALL (DETAILED BUILDING AND INSTALLATION): Likewise.
+       * lib/Makefile.am (AM_CFLAGS): New macro.
+       * m4/manywarnings.m4, m4/warnings.m4: New files, from gnulib.
+
 2012-04-17  Dmitry Antipov  <address@hidden>
 
        * configure.in (AC_CHECK_FUNCS):

=== modified file 'INSTALL'
--- a/INSTALL   2012-01-19 07:21:25 +0000
+++ b/INSTALL   2012-04-17 21:40:07 +0000
@@ -317,6 +317,12 @@
 even on hosts where a narrower type would do.  With this option, on a
 typical 32-bit host, Emacs integers have 62 bits instead of 30.
 
+Use --enable-gcc-warnings to enable compile-time checks that warn
+about possibly-questionable C code.  This is intended for developers
+and is useful with GNU-compatible compilers.  On a recent GNU system
+there should be no warnings; on older and on non-GNU systems the
+generated warnings may still be useful.
+
 The `--prefix=PREFIXDIR' option specifies where the installation process
 should put emacs and its data files.  This defaults to `/usr/local'.
 - Emacs (and the other utilities users run) go in PREFIXDIR/bin

=== modified file 'Makefile.in'
--- a/Makefile.in       2012-04-09 13:10:22 +0000
+++ b/Makefile.in       2012-04-09 19:51:06 +0000
@@ -336,8 +336,9 @@
   careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr \
   dup2 \
   filemode getloadavg getopt-gnu ignore-value intprops lstat \
-  mktime pthread_sigmask readlink \
-  socklen stdarg stdio strftime strtoimax strtoumax symlink sys_stat
+  manywarnings mktime pthread_sigmask readlink \
+  socklen stdarg stdio strftime strtoimax strtoumax symlink sys_stat \
+  warnings
 GNULIB_TOOL_FLAGS = \
  --avoid=msvc-inval --avoid=msvc-nothrow \
  --avoid=raise --avoid=threadlib \

=== modified file 'configure.in'
--- a/configure.in      2012-04-17 01:29:58 +0000
+++ b/configure.in      2012-04-18 16:40:06 +0000
@@ -686,47 +686,123 @@
   test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS"
 fi
 
-### Use -Wdeclaration-after-statement if the compiler supports it
-AC_MSG_CHECKING([whether gcc understands -Wdeclaration-after-statement])
-SAVE_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wdeclaration-after-statement"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], has_option=yes, has_option=no)
-if test $has_option = yes; then
-   C_WARNINGS_SWITCH="-Wdeclaration-after-statement $C_WARNINGS_SWITCH"
-fi
-AC_MSG_RESULT($has_option)
-CFLAGS="$SAVE_CFLAGS"
-unset has_option
-unset SAVE_CFLAGS
-
-### Use -Wold-style-definition if the compiler supports it
-# This can be removed when conversion to standard C is finished.
-AC_MSG_CHECKING([whether gcc understands -Wold-style-definition])
-SAVE_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wold-style-definition"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], has_option=yes, has_option=no)
-if test $has_option = yes; then
-   C_WARNINGS_SWITCH="-Wold-style-definition $C_WARNINGS_SWITCH"
-fi
-AC_MSG_RESULT($has_option)
-CFLAGS="$SAVE_CFLAGS"
-unset has_option
-unset SAVE_CFLAGS
-
-### Use -Wimplicit-function-declaration if the compiler supports it
-AC_MSG_CHECKING([whether gcc understands -Wimplicit-function-declaration])
-SAVE_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wimplicit-function-declaration"
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], has_option=yes, has_option=no)
-if test $has_option = yes; then
-   C_WARNINGS_SWITCH="-Wimplicit-function-declaration $C_WARNINGS_SWITCH"
-fi
-AC_MSG_RESULT($has_option)
-CFLAGS="$SAVE_CFLAGS"
-unset has_option
-unset SAVE_CFLAGS
-
-AC_SUBST(C_WARNINGS_SWITCH)
+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]
+)
+
+# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
+# ------------------------------------------------
+# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
+# Otherwise, run RUN-IF-NOT-FOUND.
+AC_DEFUN([gl_GCC_VERSION_IFELSE],
+  [AC_PREPROC_IFELSE(
+    [AC_LANG_PROGRAM(
+      [[
+#if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
+/* ok */
+#else
+# error "your version of gcc is older than $1.$2"
+#endif
+      ]]),
+    ], [$3], [$4])
+  ]
+)
+
+# When compiling with GCC, prefer -isystem to -I when including system
+# include files, to avoid generating useless diagnostics for the files.
+if test "$gl_gcc_warnings" != yes; then
+  isystem='-I'
+else
+  isystem='-isystem '
+
+  # This, $nw, is the list of warnings we disable.
+  nw=
+
+  case $with_x_toolkit in
+    lucid | athena | motif)
+       # Old toolkits mishandle 'const'.
+       nw="$nw -Wwrite-strings"
+       ;;
+    *)
+       gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
+       ;;
+  esac
+  AC_SUBST([WERROR_CFLAGS])
+
+  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 -Woverlength-strings"     # Not a problem these days
+  nw="$nw -Wtraditional-conversion" # Too many warnings for now
+  nw="$nw -Wpadded"                 # Our structs are not padded
+  nw="$nw -Wredundant-decls"        # We regularly (re)declare getenv etc.
+  nw="$nw -Wlogical-op"             # any use of fwrite provokes this
+  nw="$nw -Wformat-nonliteral"      # Emacs does this a lot
+  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 -Wfloat-equal"            # e.g., ftoastr.c
+  nw="$nw -Winline"                 # e.g., dispnew.c's inlining of row_equal_p
+
+  # Emacs doesn't care about shadowing; see
+  # <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
+  nw="$nw -Wshadow"
+
+  # The following lines should be removable at some point.
+  nw="$nw -Wstack-protector"
+  nw="$nw -Wstrict-overflow"
+  nw="$nw -Wsuggest-attribute=const"
+  nw="$nw -Wsuggest-attribute=pure"
+
+  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-type-limits])      # Too many warnings for now
+  gl_WARN_ADD([-Wno-switch])           # Too many warnings for now
+  gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
+  gl_WARN_ADD([-Wno-format-nonliteral])
+
+  # In spite of excluding -Wlogical-op above, it is enabled, as of
+  # gcc 4.5.0 20090517.
+  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 -Wunused-macros"
+
+  gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
+  AC_SUBST([GNULIB_WARN_CFLAGS])
+fi
+
 
 
 #### Some other nice autoconf tests.
@@ -1127,8 +1203,13 @@
         if $PKG_CONFIG --exists "$2" 2>&AS_MESSAGE_LOG_FD &&
           $1_CFLAGS=`$PKG_CONFIG --cflags "$2" 2>&AS_MESSAGE_LOG_FD` &&
           $1_LIBS=`$PKG_CONFIG --libs "$2" 2>&AS_MESSAGE_LOG_FD`; then
-
-           $1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e 's,///*,/,g'`
+           edit_cflags="
+             s,///*,/,g
+             s/^/ /
+             s/ -I/ $isystem/g
+             s/^ //
+           "
+           $1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"`
            $1_LIBS=`AS_ECHO(["$$1_LIBS"]) | sed -e 's,///*,/,g'`
             AC_MSG_RESULT([yes CFLAGS='$$1_CFLAGS' LIBS='$$1_LIBS'])
             succeeded=yes
@@ -1454,7 +1535,7 @@
 AC_SUBST(LD_SWITCH_X_SITE_AUX_RPATH)
 
 if test "${x_includes}" != NONE && test -n "${x_includes}"; then
-  C_SWITCH_X_SITE=-I`echo ${x_includes} | sed -e "s/:/ -I/g"`
+  C_SWITCH_X_SITE="$isystem"`echo ${x_includes} | sed -e "s/:/ $isystem/g"`
 fi
 
 if test x"${x_includes}" = x; then

=== modified file 'etc/NEWS'
--- a/etc/NEWS  2012-04-17 03:08:05 +0000
+++ b/etc/NEWS  2012-04-17 21:38:34 +0000
@@ -22,6 +22,13 @@
 
 
 * Installation Changes in Emacs 24.2
+
+** New configure option '--enable-gcc-warnings', intended for developers.
+If building with GCC, this enables compile-time checks that warn about
+possibly-questionable C code.  On a recent GNU system there should be
+no warnings; on older and on non-GNU systems the generated warnings
+may be useful.
+
 
 * Startup Changes in Emacs 24.2
 

=== modified file 'lib-src/ChangeLog'
--- a/lib-src/ChangeLog 2012-04-16 00:41:01 +0000
+++ b/lib-src/ChangeLog 2012-04-18 16:45:13 +0000
@@ -1,3 +1,10 @@
+2012-04-18  Paul Eggert  <address@hidden>
+
+       configure: new option --enable-gcc-warnings (Bug#11207)
+       * Makefile.in (C_WARNINGS_SWITCH): Remove.
+       (WARN_CFLAGS, WERROR_CFLAGS): New macros.
+       (BASE_CFLAGS): Use new macros rather than old.
+
 2012-04-16  Paul Eggert  <address@hidden>
 
        Assume less-ancient POSIX support.

=== modified file 'lib-src/Makefile.in'
--- a/lib-src/Makefile.in       2012-01-19 07:21:25 +0000
+++ b/lib-src/Makefile.in       2012-04-09 07:45:59 +0000
@@ -36,8 +36,9 @@
 address@hidden@
 address@hidden@
 address@hidden@
-C_WARNINGS_SWITCH = @C_WARNINGS_SWITCH@
 PROFILING_CFLAGS = @PROFILING_CFLAGS@
+WARN_CFLAGS = @WARN_CFLAGS@
+WERROR_CFLAGS = @WERROR_CFLAGS@
 
 # Program name transformation.
 TRANSFORM = @program_transform_name@
@@ -167,7 +168,8 @@
 # Those files shared with other GNU utilities need HAVE_CONFIG_H
 # defined before they know they can take advantage of the information
 # in ../src/config.h.
-BASE_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) ${C_WARNINGS_SWITCH} \
+BASE_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) \
+             $(WARN_CFLAGS) $(WERROR_CFLAGS) \
              -DHAVE_CONFIG_H -I. -I../src -I../lib \
              -I${srcdir} -I${srcdir}/../src -I${srcdir}/../lib
 

=== modified file 'lib/Makefile.am'
--- a/lib/Makefile.am   2011-02-20 10:51:50 +0000
+++ b/lib/Makefile.am   2012-04-09 07:45:59 +0000
@@ -4,6 +4,7 @@
 MOSTLYCLEANFILES =
 noinst_LIBRARIES =
 
+AM_CFLAGS = $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS)
 DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src
 
 include gnulib.mk

=== modified file 'lwlib/ChangeLog'
--- a/lwlib/ChangeLog   2012-04-11 01:25:51 +0000
+++ b/lwlib/ChangeLog   2012-04-18 16:45:13 +0000
@@ -1,3 +1,10 @@
+2012-04-18  Paul Eggert  <address@hidden>
+
+       configure: new option --enable-gcc-warnings (Bug#11207)
+       * Makefile.in (C_WARNINGS_SWITCH): Remove.
+       (WARN_CFLAGS, WERROR_CFLAGS): New macros.
+       (ALL_CFLAGS): Use new macros rather than old.
+
 2012-04-11  Glenn Morris  <address@hidden>
 
        * Makefile.in (C_SWITCH_X_SYSTEM): Remove.

=== modified file 'lwlib/Makefile.in'
--- a/lwlib/Makefile.in 2012-04-11 01:25:51 +0000
+++ b/lwlib/Makefile.in 2012-04-14 04:37:44 +0000
@@ -28,8 +28,9 @@
 address@hidden@
 address@hidden@
 address@hidden@
-C_WARNINGS_SWITCH = @C_WARNINGS_SWITCH@
 PROFILING_CFLAGS = @PROFILING_CFLAGS@
+WARN_CFLAGS = `echo @WARN_CFLAGS@ | sed 's/ -Wwrite-strings//'`
+WERROR_CFLAGS = @WERROR_CFLAGS@
 
 address@hidden@
 address@hidden@
@@ -53,7 +54,7 @@
 ## There are no generated lwlib files, hence no need for -I.
 ALL_CFLAGS= $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \
   $(C_SWITCH_MACHINE) \
-  $(C_WARNINGS_SWITCH) $(PROFILING_CFLAGS) $(CFLAGS) \
+  $(WARN_CFLAGS) $(WERROR_CFLAGS) $(PROFILING_CFLAGS) $(CFLAGS) \
   -DHAVE_CONFIG_H -Demacs -I../src \
   -I$(srcdir) -I$(srcdir)/../src -I../lib -I$(srcdir)/../lib
 

=== added file 'm4/manywarnings.m4'
--- a/m4/manywarnings.m4        1970-01-01 00:00:00 +0000
+++ b/m4/manywarnings.m4        2012-04-09 07:45:59 +0000
@@ -0,0 +1,184 @@
+# manywarnings.m4 serial 3
+dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Simon Josefsson
+
+# gl_MANYWARN_COMPLEMENT(OUTVAR, LISTVAR, REMOVEVAR)
+# --------------------------------------------------
+# Copy LISTVAR to OUTVAR except for the entries in REMOVEVAR.
+# Elements separated by whitespace.  In set logic terms, the function
+# does OUTVAR = LISTVAR \ REMOVEVAR.
+AC_DEFUN([gl_MANYWARN_COMPLEMENT],
+[
+  gl_warn_set=
+  set x $2; shift
+  for gl_warn_item
+  do
+    case " $3 " in
+      *" $gl_warn_item "*)
+        ;;
+      *)
+        gl_warn_set="$gl_warn_set $gl_warn_item"
+        ;;
+    esac
+  done
+  $1=$gl_warn_set
+])
+
+# gl_MANYWARN_ALL_GCC(VARIABLE)
+# -----------------------------
+# Add all documented GCC warning parameters to variable VARIABLE.
+# Note that you need to test them using gl_WARN_ADD if you want to
+# make sure your gcc understands it.
+AC_DEFUN([gl_MANYWARN_ALL_GCC],
+[
+  dnl First, check if -Wno-missing-field-initializers is needed.
+  dnl -Wmissing-field-initializers is implied by -W, but that issues
+  dnl warnings with GCC version before 4.7, for the common idiom
+  dnl of initializing types on the stack to zero, using { 0, }
+  AC_REQUIRE([AC_PROG_CC])
+  if test -n "$GCC"; then
+
+    dnl First, check -W -Werror -Wno-missing-field-initializers is supported
+    dnl with the current $CC $CFLAGS $CPPFLAGS.
+    AC_MSG_CHECKING([whether -Wno-missing-field-initializers is supported])
+    AC_CACHE_VAL([gl_cv_cc_nomfi_supported], [
+      gl_save_CFLAGS="$CFLAGS"
+      CFLAGS="$CFLAGS -W -Werror -Wno-missing-field-initializers"
+      AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM([[]], [[]])],
+        [gl_cv_cc_nomfi_supported=yes],
+        [gl_cv_cc_nomfi_supported=no])
+      CFLAGS="$gl_save_CFLAGS"])
+    AC_MSG_RESULT([$gl_cv_cc_nomfi_supported])
+
+    if test "$gl_cv_cc_nomfi_supported" = yes; then
+      dnl Now check whether -Wno-missing-field-initializers is needed
+      dnl for the { 0, } construct.
+      AC_MSG_CHECKING([whether -Wno-missing-field-initializers is needed])
+      AC_CACHE_VAL([gl_cv_cc_nomfi_needed], [
+        gl_save_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS -W -Werror"
+        AC_COMPILE_IFELSE(
+          [AC_LANG_PROGRAM(
+             [[void f (void)
+               {
+                 typedef struct { int a; int b; } s_t;
+                 s_t s1 = { 0, };
+               }
+             ]],
+             [[]])],
+          [gl_cv_cc_nomfi_needed=no],
+          [gl_cv_cc_nomfi_needed=yes])
+        CFLAGS="$gl_save_CFLAGS"
+      ])
+      AC_MSG_RESULT([$gl_cv_cc_nomfi_needed])
+    fi
+  fi
+
+  gl_manywarn_set=
+  for gl_manywarn_item in \
+    -Wall \
+    -W \
+    -Wformat-y2k \
+    -Wformat-nonliteral \
+    -Wformat-security \
+    -Winit-self \
+    -Wmissing-include-dirs \
+    -Wswitch-default \
+    -Wswitch-enum \
+    -Wunused \
+    -Wunknown-pragmas \
+    -Wstrict-aliasing \
+    -Wstrict-overflow \
+    -Wsystem-headers \
+    -Wfloat-equal \
+    -Wtraditional \
+    -Wtraditional-conversion \
+    -Wdeclaration-after-statement \
+    -Wundef \
+    -Wshadow \
+    -Wunsafe-loop-optimizations \
+    -Wpointer-arith \
+    -Wbad-function-cast \
+    -Wc++-compat \
+    -Wcast-qual \
+    -Wcast-align \
+    -Wwrite-strings \
+    -Wconversion \
+    -Wsign-conversion \
+    -Wlogical-op \
+    -Waggregate-return \
+    -Wstrict-prototypes \
+    -Wold-style-definition \
+    -Wmissing-prototypes \
+    -Wmissing-declarations \
+    -Wmissing-noreturn \
+    -Wmissing-format-attribute \
+    -Wpacked \
+    -Wpadded \
+    -Wredundant-decls \
+    -Wnested-externs \
+    -Wunreachable-code \
+    -Winline \
+    -Winvalid-pch \
+    -Wlong-long \
+    -Wvla \
+    -Wvolatile-register-var \
+    -Wdisabled-optimization \
+    -Wstack-protector \
+    -Woverlength-strings \
+    -Wbuiltin-macro-redefined \
+    -Wmudflap \
+    -Wpacked-bitfield-compat \
+    -Wsync-nand \
+    ; do
+    gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
+  done
+  # The following are not documented in the manual but are included in
+  # output from gcc --help=warnings.
+  for gl_manywarn_item in \
+    -Wattributes \
+    -Wcoverage-mismatch \
+    -Wmultichar \
+    -Wunused-macros \
+    ; do
+    gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
+  done
+  # More warnings from gcc 4.6.2 --help=warnings.
+  for gl_manywarn_item in \
+    -Wabi \
+    -Wcpp \
+    -Wdeprecated \
+    -Wdeprecated-declarations \
+    -Wdiv-by-zero \
+    -Wdouble-promotion \
+    -Wendif-labels \
+    -Wextra \
+    -Wformat-contains-nul \
+    -Wformat-extra-args \
+    -Wformat-zero-length \
+    -Wformat=2 \
+    -Wmultichar \
+    -Wnormalized=nfc \
+    -Woverflow \
+    -Wpointer-to-int-cast \
+    -Wpragmas \
+    -Wsuggest-attribute=const \
+    -Wsuggest-attribute=noreturn \
+    -Wsuggest-attribute=pure \
+    -Wtrampolines \
+    ; do
+    gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
+  done
+
+  # Disable the missing-field-initializers warning if needed
+  if test "$gl_cv_cc_nomfi_needed" = yes; then
+    gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers"
+  fi
+
+  $1=$gl_manywarn_set
+])

=== added file 'm4/warnings.m4'
--- a/m4/warnings.m4    1970-01-01 00:00:00 +0000
+++ b/m4/warnings.m4    2012-04-09 07:45:59 +0000
@@ -0,0 +1,42 @@
+# warnings.m4 serial 6
+dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Simon Josefsson
+
+# gl_AS_VAR_APPEND(VAR, VALUE)
+# ----------------------------
+# Provide the functionality of AS_VAR_APPEND if Autoconf does not have it.
+m4_ifdef([AS_VAR_APPEND],
+[m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])],
+[m4_define([gl_AS_VAR_APPEND],
+[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
+
+
+# gl_WARN_ADD(PARAMETER, [VARIABLE = WARN_CFLAGS])
+# ------------------------------------------------
+# Adds parameter to WARN_CFLAGS if the compiler supports it.  For example,
+# gl_WARN_ADD([-Wparentheses]).
+#
+# If VARIABLE is a variable name, AC_SUBST it.
+AC_DEFUN([gl_WARN_ADD],
+dnl FIXME: gl_Warn must be used unquoted until we can assume
+dnl autoconf 2.64 or newer.
+[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl
+AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [
+  gl_save_compiler_FLAGS="$gl_Flags"
+  gl_Flags="$gl_Flags $1"
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+                    [AS_VAR_SET(gl_Warn, [yes])],
+                    [AS_VAR_SET(gl_Warn, [no])])
+  gl_Flags="$gl_save_compiler_FLAGS"
+])
+AS_VAR_IF(gl_Warn, [yes],
+  [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])])
+AS_VAR_POPDEF([gl_Flags])dnl
+AS_VAR_POPDEF([gl_Warn])dnl
+m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl
+])

=== modified file 'msdos/ChangeLog'
--- a/msdos/ChangeLog   2012-04-11 01:25:51 +0000
+++ b/msdos/ChangeLog   2012-04-18 16:45:13 +0000
@@ -1,3 +1,9 @@
+2012-04-18  Paul Eggert  <address@hidden>
+
+       configure: new option --enable-gcc-warnings (Bug#11207)
+       * sed1v2.inp, sed3v2.inp, sedlibmk.inp: GNULIB_WARN_CFLAGS,
+       WARN_CFLAGS, and WERROR_CFLAGS replace C_WARNINGS_SWITCH.
+
 2012-04-11  Glenn Morris  <address@hidden>
 
        * sedlibmk.inp, sed1v2.inp: GNUSTEP_CFLAGS replaces C_SWITCH_X_SYSTEM.

=== modified file 'msdos/sed1v2.inp'
--- a/msdos/sed1v2.inp  2012-04-11 01:25:51 +0000
+++ b/msdos/sed1v2.inp  2012-04-14 05:04:54 +0000
@@ -41,7 +41,8 @@
 /^C_SWITCH_SYSTEM *=/s/@C_SWITCH_SYSTEM@//
 /^GNUSTEP_CFLAGS *=/s/@GNUSTEP_CFLAGS@//
 /^C_SWITCH_X_SITE *=/s/@C_SWITCH_X_SITE@//
-/^C_WARNINGS_SWITCH *=/s/@C_WARNINGS_SWITCH@//
+/^WARN_CFLAGS *=/s/@WARN_CFLAGS@//
+/^WERROR_CFLAGS *=/s/@WERROR_CFLAGS@//
 /^PROFILING_CFLAGS *=/s/@PROFILING_CFLAGS@//
 #/^LD_SWITCH_X_SITE *=/s/@LD_SWITCH_X_SITE@//
 /^LD_SWITCH_SYSTEM_TEMACS *=/s/@LD_SWITCH_SYSTEM_TEMACS@//

=== modified file 'msdos/sed3v2.inp'
--- a/msdos/sed3v2.inp  2012-02-04 08:03:49 +0000
+++ b/msdos/sed3v2.inp  2012-04-14 05:04:54 +0000
@@ -38,7 +38,8 @@
 /^CFLAGS *=/s!=.*$!=-O2 -g!
 /^C_SWITCH_SYSTEM *=/s!=.*$!=-DMSDOS!
 /^C_SWITCH_MACHINE *=/s/@C_SWITCH_MACHINE@//
-/^C_WARNINGS_SWITCH *=/s/@C_WARNINGS_SWITCH@//
+/^WARN_CFLAGS *=/s/@WARN_CFLAGS@//
+/^WERROR_CFLAGS *=/s/@WERROR_CFLAGS@//
 /^PROFILING_CFLAGS *=/s/@PROFILING_CFLAGS@//
 /^ALLOCA *=/address@hidden@!!
 /^EXEEXT *=/address@hidden@!!
@@ -51,4 +52,3 @@
 }
 /^insrcdir=/s/^.*$/\#&/
 /^      *\$(insrcdir) ||/s,\$(insrcdir) ||,command.com /c if not exist $(<F),
-

=== modified file 'msdos/sedlibmk.inp'
--- a/msdos/sedlibmk.inp        2012-04-11 01:25:51 +0000
+++ b/msdos/sedlibmk.inp        2012-04-14 05:04:54 +0000
@@ -27,7 +27,7 @@
 #    otherwise edit them to zero:
 #
 #     /^REPLACE_CALLOC *=/s/@REPLACE_CALLOC@/0/
-# 
+#
 #  . If the module is a header or adds headers, edit the corresponding
 #    variable to either an empty value or to the name of the header.
 #    Examples:
@@ -126,7 +126,9 @@
 /^C_SWITCH_SYSTEM *=/s/@C_SWITCH_SYSTEM@//
 /^GNUSTEP_CFLAGS *=/s/@GNUSTEP_CFLAGS@//
 /^C_SWITCH_X_SITE *=/s/@C_SWITCH_X_SITE@//
-/^C_WARNINGS_SWITCH *=/s/@C_WARNINGS_SWITCH@//
+/^GNULIB_WARN_CFLAGS *=/s/@GNULIB_WARN_CFLAGS@//
+/^WARN_CFLAGS *=/s/@WARN_CFLAGS@//
+/^WERROR_CFLAGS *=/s/@WERROR_CFLAGS@//
 /^DEFS *=/s/@address@hidden@/-DHAVE_CONFIG_H/
 /^DEPDIR *=/s/@address@hidden@/deps/
 /^DEPFLAGS *=/s/@address@hidden@/-MMD -MF ${DEPDIR}\/$*.d/

=== modified file 'oldXMenu/ChangeLog'
--- a/oldXMenu/ChangeLog        2012-04-11 01:25:51 +0000
+++ b/oldXMenu/ChangeLog        2012-04-18 16:45:13 +0000
@@ -1,3 +1,10 @@
+2012-04-18  Paul Eggert  <address@hidden>
+
+       configure: new option --enable-gcc-warnings (Bug#11207)
+       * Makefile.in (C_WARNINGS_SWITCH): Remove.
+       (WARN_CFLAGS, WERROR_CFLAGS): New macros.
+       (ALL_CFLAGS): Use new macros rather than old.
+
 2012-04-11  Glenn Morris  <address@hidden>
 
        * Makefile.in (C_SWITCH_X_SYSTEM): Remove.

=== modified file 'oldXMenu/Makefile.in'
--- a/oldXMenu/Makefile.in      2012-04-11 01:25:51 +0000
+++ b/oldXMenu/Makefile.in      2012-04-14 04:37:44 +0000
@@ -1,4 +1,4 @@
-## Makefile for oldXMenu 
+## Makefile for oldXMenu
 
 ## Copyright 1985, 1986, 1987 by the Massachusetts Institute of Technology
 
@@ -47,8 +47,9 @@
 address@hidden@
 address@hidden@
 address@hidden@
-C_WARNINGS_SWITCH = @C_WARNINGS_SWITCH@
 PROFILING_CFLAGS = @PROFILING_CFLAGS@
+WARN_CFLAGS = @WARN_CFLAGS@
+WERROR_CFLAGS = @WERROR_CFLAGS@
 
 EXTRA=insque.o
 address@hidden@
@@ -88,7 +89,7 @@
 
 ALL_CFLAGS=$(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) \
   $(C_SWITCH_X_SITE) \
-  ${C_WARNINGS_SWITCH} ${PROFILING_CFLAGS} \
+  $(WARN_CFLAGS) $(WERROR_CFLAGS) ${PROFILING_CFLAGS} \
   $(CPPFLAGS) $(CFLAGS) -DEMACS_BITMAP_FILES \
   -I../src -I${srcdir} -I${srcdir}/../src
 

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-04-17 22:56:06 +0000
+++ b/src/ChangeLog     2012-04-18 16:45:13 +0000
@@ -1,3 +1,16 @@
+2012-04-18  Paul Eggert  <address@hidden>
+
+       configure: new option --enable-gcc-warnings (Bug#11207)
+       * Makefile.in (C_WARNINGS_SWITCH): Remove.
+       (WARN_CFLAGS, WERROR_CFLAGS): New macros.
+       (ALL_CFLAGS): Use new macros rather than old.
+       * process.c: Ignore -Wstrict-overflow to work around GCC bug 52904.
+       * regex.c: Ignore -Wstrict-overflow.  If !emacs, also ignore
+       -Wunused-but-set-variable, -Wunused-function, -Wunused-macros,
+       -Wunused-result, -Wunused-variable.  This should go away once
+       the Emacs and Gnulib regex code is merged.
+       (xmalloc, xrealloc): Now static.
+
 2012-04-17  Paul Eggert  <address@hidden>
 
        * dired.c (Fsystem_groups): Remove unused local.

=== modified file 'src/Makefile.in'
--- a/src/Makefile.in   2012-04-11 01:25:51 +0000
+++ b/src/Makefile.in   2012-04-14 04:37:44 +0000
@@ -68,7 +68,8 @@
 PROFILING_CFLAGS = @PROFILING_CFLAGS@
 
 ## Flags to pass to the compiler to enable build warnings
-C_WARNINGS_SWITCH = @C_WARNINGS_SWITCH@
+WARN_CFLAGS = @WARN_CFLAGS@
+WERROR_CFLAGS = @WERROR_CFLAGS@
 
 ## Machine-specific CFLAGS.
 address@hidden@
@@ -308,7 +309,7 @@
   $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \
   $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) $(PROFILING_CFLAGS) \
   $(LIBGNUTLS_CFLAGS) \
-  $(C_WARNINGS_SWITCH) $(CFLAGS)
+  $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAGS)
 ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS)
 
 .SUFFIXES: .m

=== modified file 'src/process.c'
--- a/src/process.c     2012-04-14 01:46:06 +0000
+++ b/src/process.c     2012-04-14 04:37:44 +0000
@@ -120,6 +120,13 @@
 #include "nsterm.h"
 #endif
 
+/* Work around GCC 4.7.0 bug with strict overflow checking; see
+   <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
+   These lines can be removed once the GCC bug is fixed.  */
+#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wstrict-overflow"
+#endif
+
 Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
 Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
 Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;

=== modified file 'src/regex.c'
--- a/src/regex.c       2012-01-19 07:21:25 +0000
+++ b/src/regex.c       2012-04-09 07:45:59 +0000
@@ -33,6 +33,19 @@
   #pragma alloca
 #endif
 
+/* Ignore some GCC warnings for now.  This section should go away
+   once the Emacs and Gnulib regex code is merged.  */
+#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wstrict-overflow"
+# ifndef emacs
+#  pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#  pragma GCC diagnostic ignored "-Wunused-function"
+#  pragma GCC diagnostic ignored "-Wunused-macros"
+#  pragma GCC diagnostic ignored "-Wunused-result"
+#  pragma GCC diagnostic ignored "-Wunused-variable"
+# endif
+#endif
+
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
@@ -198,7 +211,7 @@
 
 /* When used in Emacs's lib-src, we need xmalloc and xrealloc. */
 
-void *
+static void *
 xmalloc (size_t size)
 {
   register void *val;
@@ -211,7 +224,7 @@
   return val;
 }
 
-void *
+static void *
 xrealloc (void *block, size_t size)
 {
   register void *val;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]