bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#11207: configure: new option --enable-gcc-warnings


From: Paul Eggert
Subject: bug#11207: configure: new option --enable-gcc-warnings
Date: Mon, 09 Apr 2012 00:58:00 -0700
User-agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120329 Thunderbird/11.0.1

Package: emacs
Version: 24.1
Tags: patch

Here's a patch to add a 'configure' option --enable-gcc-warnings that
enables GCC static checking options that I've found useful for
checking Emacs.  It uses code borrowed from GNU coreutils, which has
this option in its 'configure' script.  I've been using this for many
months to find bugs in Emacs, and it's mature enough to publish now.
I'd like to install it into the trunk at an appropriate time.


# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: eggert@cs.ucla.edu-20120409074559-3m1t6s9bhkz1cb62
# target_branch: bzr+ssh://eggert@bzr.savannah.gnu.org/emacs/trunk
# testament_sha1: 5a97b04aaf25a2e78f8bd8320c615579bbd78566
# timestamp: 2012-04-09 00:46:35 -0700
# base_revision_id: eggert@cs.ucla.edu-20120409065240-02ros2knvxqadia4
# 
# Begin patch
=== modified file 'ChangeLog'
--- ChangeLog   2012-04-09 06:40:20 +0000
+++ ChangeLog   2012-04-09 07:45:59 +0000
@@ -1,3 +1,20 @@
+2012-04-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+       configure: new option --enable-gcc-warnings
+       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.
+       * lib/Makefile.am (AM_CFLAGS): New macro.
+       * m4/manywarnings.m4, m4/warnings.m4: New files, from gnulib.
+
 2012-04-09  Glenn Morris  <rgm@gnu.org>
 
        * Makefile.in (leim): Check cd return value.  Pass fewer variables.

=== modified file 'Makefile.in'
--- Makefile.in 2012-04-09 06:40:20 +0000
+++ Makefile.in 2012-04-09 07:45:59 +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'
--- configure.in        2012-04-09 00:50:17 +0000
+++ configure.in        2012-04-09 07:45:59 +0000
@@ -686,47 +686,121 @@
   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 -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 +1201,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
@@ -1463,7 +1542,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'
--- etc/NEWS    2012-04-07 19:51:51 +0000
+++ etc/NEWS    2012-04-09 07:45:59 +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 or may not be useful.  By default, these warnings are not generated.
+
 
 * Startup Changes in Emacs 24.2
 

=== modified file 'lib-src/ChangeLog'
--- lib-src/ChangeLog   2012-04-07 13:57:36 +0000
+++ lib-src/ChangeLog   2012-04-09 07:45:59 +0000
@@ -1,3 +1,10 @@
+2012-04-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+       configure: new option --enable-gcc-warnings
+       * Makefile.in (C_WARNINGS_SWITCH): Remove.
+       (WARN_CFLAGS, WERROR_CFLAGS): New macros.
+       (BASE_CFLAGS): Use new macros rather than old.
+
 2012-04-07  Eli Zaretskii  <eliz@gnu.org>
 
        * makefile.w32-in (obj): Add xml.o.

=== modified file 'lib-src/Makefile.in'
--- lib-src/Makefile.in 2012-01-19 07:21:25 +0000
+++ lib-src/Makefile.in 2012-04-09 07:45:59 +0000
@@ -36,8 +36,9 @@
 EXEEXT=@EXEEXT@
 C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@
 C_SWITCH_MACHINE=@C_SWITCH_MACHINE@
-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'
--- lib/Makefile.am     2011-02-20 10:51:50 +0000
+++ 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'
--- lwlib/ChangeLog     2012-02-09 07:48:22 +0000
+++ lwlib/ChangeLog     2012-04-09 07:45:59 +0000
@@ -1,3 +1,10 @@
+2012-04-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+       configure: new option --enable-gcc-warnings
+       * Makefile.in (C_WARNINGS_SWITCH): Remove.
+       (WARN_CFLAGS, WERROR_CFLAGS): New macros.
+       (ALL_CFLAGS): Use new macros rather than old.
+
 2011-10-13  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * lwlib-Xaw.c (openFont, xaw_destroy_instance): Replace free with

=== modified file 'lwlib/Makefile.in'
--- lwlib/Makefile.in   2012-01-19 07:21:25 +0000
+++ lwlib/Makefile.in   2012-04-09 07:45:59 +0000
@@ -29,8 +29,9 @@
 C_SWITCH_X_SYSTEM=@C_SWITCH_X_SYSTEM@
 C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@
 C_SWITCH_MACHINE=@C_SWITCH_MACHINE@
-C_WARNINGS_SWITCH = @C_WARNINGS_SWITCH@
 PROFILING_CFLAGS = @PROFILING_CFLAGS@
+WARN_CFLAGS = `echo @WARN_CFLAGS@ | sed 's/ -Wwrite-strings//'`
+WERROR_CFLAGS = @WERROR_CFLAGS@
 
 CC=@CC@
 CFLAGS=@CFLAGS@
@@ -54,7 +55,8 @@
 ## There are no generated lwlib files, hence no need for -I.
 ALL_CFLAGS= $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \
   $(C_SWITCH_X_SYSTEM) $(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'
--- m4/manywarnings.m4  1970-01-01 00:00:00 +0000
+++ 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'
--- m4/warnings.m4      1970-01-01 00:00:00 +0000
+++ 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 'oldXMenu/ChangeLog'
--- oldXMenu/ChangeLog  2012-02-09 07:48:22 +0000
+++ oldXMenu/ChangeLog  2012-04-09 07:45:59 +0000
@@ -1,3 +1,10 @@
+2012-04-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+       configure: new option --enable-gcc-warnings
+       * Makefile.in (C_WARNINGS_SWITCH): Remove.
+       (WARN_CFLAGS, WERROR_CFLAGS): New macros.
+       (ALL_CFLAGS): Use new macros rather than old.
+
 2011-04-16  Paul Eggert  <eggert@cs.ucla.edu>
 
        Static checks with GCC 4.6.0 and non-default toolkits.

=== modified file 'oldXMenu/Makefile.in'
--- oldXMenu/Makefile.in        2012-01-19 07:21:25 +0000
+++ oldXMenu/Makefile.in        2012-04-09 07:45:59 +0000
@@ -48,8 +48,9 @@
 C_SWITCH_X_SYSTEM=@C_SWITCH_X_SYSTEM@
 C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@
 C_SWITCH_MACHINE=@C_SWITCH_MACHINE@
-C_WARNINGS_SWITCH = @C_WARNINGS_SWITCH@
 PROFILING_CFLAGS = @PROFILING_CFLAGS@
+WARN_CFLAGS = @WARN_CFLAGS@
+WERROR_CFLAGS = @WERROR_CFLAGS@
 
 EXTRA=insque.o
 CC=@CC@
@@ -89,7 +90,7 @@
 
 ALL_CFLAGS=$(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) \
   $(C_SWITCH_X_SITE) $(C_SWITCH_X_SYSTEM) \
-  ${C_WARNINGS_SWITCH} ${PROFILING_CFLAGS} \
+  $(WARN_CFLAGS) $(WERROR_CFLAGS) ${C_WARNINGS_SWITCH} ${PROFILING_CFLAGS} \
   $(CPPFLAGS) $(CFLAGS) -DEMACS_BITMAP_FILES \
   -I../src -I${srcdir} -I${srcdir}/../src
 

=== modified file 'src/ChangeLog'
--- src/ChangeLog       2012-04-09 06:52:40 +0000
+++ src/ChangeLog       2012-04-09 07:45:59 +0000
@@ -1,5 +1,18 @@
 2012-04-09  Paul Eggert  <eggert@cs.ucla.edu>
 
+       configure: new option --enable-gcc-warnings
+       * 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-09  Paul Eggert  <eggert@cs.ucla.edu>
+
        composite.c: use 'double' consistently
        * composite.c (get_composition_id): Use 'double' consistently
        instead of converting 'float' to 'double' and vice versa; this is

=== modified file 'src/Makefile.in'
--- src/Makefile.in     2012-04-09 06:47:33 +0000
+++ src/Makefile.in     2012-04-09 07:45:59 +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.
 C_SWITCH_MACHINE=@C_SWITCH_MACHINE@
@@ -314,7 +315,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'
--- src/process.c       2012-03-23 12:23:14 +0000
+++ src/process.c       2012-04-09 07:45:59 +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'
--- src/regex.c 2012-01-19 07:21:25 +0000
+++ 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]