aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--Makefile.in5
-rw-r--r--configure.in167
-rw-r--r--etc/NEWS7
-rw-r--r--lib-src/ChangeLog7
-rw-r--r--lib-src/Makefile.in6
-rw-r--r--lib/Makefile.am1
-rw-r--r--lwlib/ChangeLog7
-rw-r--r--lwlib/Makefile.in6
-rw-r--r--m4/manywarnings.m4184
-rw-r--r--m4/warnings.m442
-rw-r--r--oldXMenu/ChangeLog7
-rw-r--r--oldXMenu/Makefile.in5
-rw-r--r--src/ChangeLog13
-rw-r--r--src/Makefile.in5
-rw-r--r--src/process.c7
-rw-r--r--src/regex.c17
17 files changed, 447 insertions, 56 deletions
diff --git a/ChangeLog b/ChangeLog
index 2fe50a6d83b..8f7ccc573af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
12012-04-09 Paul Eggert <eggert@cs.ucla.edu>
2
3 configure: new option --enable-gcc-warnings
4 I have been using this change for many months in my private copy
5 of Emacs, and have used it to find several bugs. It's mature
6 enough to publish now.
7 * Makefile.in (GNULIB_MODULES): Add warnings, manywarnings.
8 * configure.in: Support --enable-gcc-warnings, in the style of
9 other GNU packages such as coreutils.
10 (C_WARNINGS_SWITCH): Remove, replacing with...
11 (WARN_CFLAGS, GNULIB_WARN_CFLAGS): New variable.
12 (PKG_CHECK_MODULES, C_SWITCH_X_SITE): Use -isystem rather than -I,
13 when including system files with GCC.
14 * etc/NEWS: Mention --enable-gcc-warnings.
15 * lib/Makefile.am (AM_CFLAGS): New macro.
16 * m4/manywarnings.m4, m4/warnings.m4: New files, from gnulib.
17
12012-04-09 Glenn Morris <rgm@gnu.org> 182012-04-09 Glenn Morris <rgm@gnu.org>
2 19
3 * Makefile.in (leim): Check cd return value. Pass fewer variables. 20 * Makefile.in (leim): Check cd return value. Pass fewer variables.
diff --git a/Makefile.in b/Makefile.in
index 3ee5e8ae8ed..2d54aa1f3a3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -336,8 +336,9 @@ GNULIB_MODULES = \
336 careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr \ 336 careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr \
337 dup2 \ 337 dup2 \
338 filemode getloadavg getopt-gnu ignore-value intprops lstat \ 338 filemode getloadavg getopt-gnu ignore-value intprops lstat \
339 mktime pthread_sigmask readlink \ 339 manywarnings mktime pthread_sigmask readlink \
340 socklen stdarg stdio strftime strtoimax strtoumax symlink sys_stat 340 socklen stdarg stdio strftime strtoimax strtoumax symlink sys_stat \
341 warnings
341GNULIB_TOOL_FLAGS = \ 342GNULIB_TOOL_FLAGS = \
342 --avoid=msvc-inval --avoid=msvc-nothrow \ 343 --avoid=msvc-inval --avoid=msvc-nothrow \
343 --avoid=raise --avoid=threadlib \ 344 --avoid=raise --avoid=threadlib \
diff --git a/configure.in b/configure.in
index 14a80622cd9..4b67078bf39 100644
--- a/configure.in
+++ b/configure.in
@@ -686,47 +686,121 @@ else
686 test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS" 686 test "x$NON_GCC_TEST_OPTIONS" != x && CC="$CC $NON_GCC_TEST_OPTIONS"
687fi 687fi
688 688
689### Use -Wdeclaration-after-statement if the compiler supports it 689AC_ARG_ENABLE([gcc-warnings],
690AC_MSG_CHECKING([whether gcc understands -Wdeclaration-after-statement]) 690 [AS_HELP_STRING([--enable-gcc-warnings],
691SAVE_CFLAGS="$CFLAGS" 691 [turn on lots of GCC warnings (for developers)])],
692CFLAGS="$CFLAGS -Wdeclaration-after-statement" 692 [case $enableval in
693AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], has_option=yes, has_option=no) 693 yes|no) ;;
694if test $has_option = yes; then 694 *) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
695 C_WARNINGS_SWITCH="-Wdeclaration-after-statement $C_WARNINGS_SWITCH" 695 esac
696fi 696 gl_gcc_warnings=$enableval],
697AC_MSG_RESULT($has_option) 697 [gl_gcc_warnings=no]
698CFLAGS="$SAVE_CFLAGS" 698)
699unset has_option 699
700unset SAVE_CFLAGS 700# gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found])
701 701# ------------------------------------------------
702### Use -Wold-style-definition if the compiler supports it 702# If $CPP is gcc-MAJOR.MINOR or newer, then run RUN-IF-FOUND.
703# This can be removed when conversion to standard C is finished. 703# Otherwise, run RUN-IF-NOT-FOUND.
704AC_MSG_CHECKING([whether gcc understands -Wold-style-definition]) 704AC_DEFUN([gl_GCC_VERSION_IFELSE],
705SAVE_CFLAGS="$CFLAGS" 705 [AC_PREPROC_IFELSE(
706CFLAGS="$CFLAGS -Wold-style-definition" 706 [AC_LANG_PROGRAM(
707AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], has_option=yes, has_option=no) 707 [[
708if test $has_option = yes; then 708#if ($1) < __GNUC__ || (($1) == __GNUC__ && ($2) <= __GNUC_MINOR__)
709 C_WARNINGS_SWITCH="-Wold-style-definition $C_WARNINGS_SWITCH" 709/* ok */
710fi 710#else
711AC_MSG_RESULT($has_option) 711# error "your version of gcc is older than $1.$2"
712CFLAGS="$SAVE_CFLAGS" 712#endif
713unset has_option 713 ]]),
714unset SAVE_CFLAGS 714 ], [$3], [$4])
715 715 ]
716### Use -Wimplicit-function-declaration if the compiler supports it 716)
717AC_MSG_CHECKING([whether gcc understands -Wimplicit-function-declaration]) 717
718SAVE_CFLAGS="$CFLAGS" 718# When compiling with GCC, prefer -isystem to -I when including system
719CFLAGS="$CFLAGS -Wimplicit-function-declaration" 719# include files, to avoid generating useless diagnostics for the files.
720AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], has_option=yes, has_option=no) 720if test "$gl_gcc_warnings" != yes; then
721if test $has_option = yes; then 721 isystem='-I'
722 C_WARNINGS_SWITCH="-Wimplicit-function-declaration $C_WARNINGS_SWITCH" 722else
723fi 723 isystem='-isystem '
724AC_MSG_RESULT($has_option) 724
725CFLAGS="$SAVE_CFLAGS" 725 # This, $nw, is the list of warnings we disable.
726unset has_option 726 nw=
727unset SAVE_CFLAGS 727
728 728 case $with_x_toolkit in
729AC_SUBST(C_WARNINGS_SWITCH) 729 lucid | athena | motif)
730 # Old toolkits mishandle 'const'.
731 nw="$nw -Wwrite-strings"
732 ;;
733 *)
734 gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
735 ;;
736 esac
737 AC_SUBST([WERROR_CFLAGS])
738
739 nw="$nw -Waggregate-return" # anachronistic
740 nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h)
741 nw="$nw -Wc++-compat" # We don't care about C++ compilers
742 nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib
743 nw="$nw -Wtraditional" # Warns on #elif which we use often
744 nw="$nw -Wcast-qual" # Too many warnings for now
745 nw="$nw -Wconversion" # Too many warnings for now
746 nw="$nw -Wsystem-headers" # Don't let system headers trigger warnings
747 nw="$nw -Wsign-conversion" # Too many warnings for now
748 nw="$nw -Woverlength-strings" # Not a problem these days
749 nw="$nw -Wtraditional-conversion" # Too many warnings for now
750 nw="$nw -Wpadded" # Our structs are not padded
751 nw="$nw -Wredundant-decls" # We regularly (re)declare getenv etc.
752 nw="$nw -Wlogical-op" # any use of fwrite provokes this
753 nw="$nw -Wformat-nonliteral" # Emacs does this a lot
754 nw="$nw -Wvla" # warnings in gettext.h
755 nw="$nw -Wnested-externs" # use of XARGMATCH/verify_function__
756 nw="$nw -Wswitch-enum" # Too many warnings for now
757 nw="$nw -Wswitch-default" # Too many warnings for now
758 nw="$nw -Wfloat-equal" # e.g., ftoastr.c
759 nw="$nw -Winline" # e.g., dispnew.c's inlining of row_equal_p
760
761 # Emacs doesn't care about shadowing; see
762 # <http://lists.gnu.org/archive/html/emacs-diffs/2011-11/msg00265.html>.
763 nw="$nw -Wshadow"
764
765 # The following lines should be removable at some point.
766 nw="$nw -Wsuggest-attribute=const"
767 nw="$nw -Wsuggest-attribute=pure"
768
769 gl_MANYWARN_ALL_GCC([ws])
770 gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
771 for w in $ws; do
772 gl_WARN_ADD([$w])
773 done
774 gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
775 gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
776 gl_WARN_ADD([-Wno-type-limits]) # Too many warnings for now
777 gl_WARN_ADD([-Wno-switch]) # Too many warnings for now
778 gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
779 gl_WARN_ADD([-Wno-format-nonliteral])
780
781 # In spite of excluding -Wlogical-op above, it is enabled, as of
782 # gcc 4.5.0 20090517.
783 gl_WARN_ADD([-Wno-logical-op])
784
785 gl_WARN_ADD([-fdiagnostics-show-option])
786 gl_WARN_ADD([-funit-at-a-time])
787
788 AC_SUBST([WARN_CFLAGS])
789
790 AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.])
791 AC_DEFINE([_FORTIFY_SOURCE], [2],
792 [enable compile-time and run-time bounds-checking, and some warnings])
793 AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
794
795 # We use a slightly smaller set of warning options for lib/.
796 # Remove the following and save the result in GNULIB_WARN_CFLAGS.
797 nw=
798 nw="$nw -Wunused-macros"
799
800 gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
801 AC_SUBST([GNULIB_WARN_CFLAGS])
802fi
803
730 804
731 805
732#### Some other nice autoconf tests. 806#### Some other nice autoconf tests.
@@ -1127,8 +1201,13 @@ AC_DEFUN([PKG_CHECK_MODULES], [
1127 if $PKG_CONFIG --exists "$2" 2>&AS_MESSAGE_LOG_FD && 1201 if $PKG_CONFIG --exists "$2" 2>&AS_MESSAGE_LOG_FD &&
1128 $1_CFLAGS=`$PKG_CONFIG --cflags "$2" 2>&AS_MESSAGE_LOG_FD` && 1202 $1_CFLAGS=`$PKG_CONFIG --cflags "$2" 2>&AS_MESSAGE_LOG_FD` &&
1129 $1_LIBS=`$PKG_CONFIG --libs "$2" 2>&AS_MESSAGE_LOG_FD`; then 1203 $1_LIBS=`$PKG_CONFIG --libs "$2" 2>&AS_MESSAGE_LOG_FD`; then
1130 1204 edit_cflags="
1131 $1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e 's,///*,/,g'` 1205 s,///*,/,g
1206 s/^/ /
1207 s/ -I/ $isystem/g
1208 s/^ //
1209 "
1210 $1_CFLAGS=`AS_ECHO(["$$1_CFLAGS"]) | sed -e "$edit_cflags"`
1132 $1_LIBS=`AS_ECHO(["$$1_LIBS"]) | sed -e 's,///*,/,g'` 1211 $1_LIBS=`AS_ECHO(["$$1_LIBS"]) | sed -e 's,///*,/,g'`
1133 AC_MSG_RESULT([yes CFLAGS='$$1_CFLAGS' LIBS='$$1_LIBS']) 1212 AC_MSG_RESULT([yes CFLAGS='$$1_CFLAGS' LIBS='$$1_LIBS'])
1134 succeeded=yes 1213 succeeded=yes
@@ -1463,7 +1542,7 @@ AC_SUBST(LD_SWITCH_X_SITE_AUX)
1463AC_SUBST(LD_SWITCH_X_SITE_AUX_RPATH) 1542AC_SUBST(LD_SWITCH_X_SITE_AUX_RPATH)
1464 1543
1465if test "${x_includes}" != NONE && test -n "${x_includes}"; then 1544if test "${x_includes}" != NONE && test -n "${x_includes}"; then
1466 C_SWITCH_X_SITE=-I`echo ${x_includes} | sed -e "s/:/ -I/g"` 1545 C_SWITCH_X_SITE="$isystem"`echo ${x_includes} | sed -e "s/:/ $isystem/g"`
1467fi 1546fi
1468 1547
1469if test x"${x_includes}" = x; then 1548if test x"${x_includes}" = x; then
diff --git a/etc/NEWS b/etc/NEWS
index ae6ba8d36b7..dd302a052d6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -22,6 +22,13 @@ so we will look at it and add it to the manual.
22 22
23 23
24* Installation Changes in Emacs 24.2 24* Installation Changes in Emacs 24.2
25
26** New configure option '--enable-gcc-warnings', intended for developers.
27If building with GCC, this enables compile-time checks that warn about
28possibly-questionable C code. On a recent GNU system there should be
29no warnings; on older and on non-GNU systems the generated warnings
30may or may not be useful. By default, these warnings are not generated.
31
25 32
26* Startup Changes in Emacs 24.2 33* Startup Changes in Emacs 24.2
27 34
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index aad382de6d0..86b92b5b84a 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,10 @@
12012-04-09 Paul Eggert <eggert@cs.ucla.edu>
2
3 configure: new option --enable-gcc-warnings
4 * Makefile.in (C_WARNINGS_SWITCH): Remove.
5 (WARN_CFLAGS, WERROR_CFLAGS): New macros.
6 (BASE_CFLAGS): Use new macros rather than old.
7
12012-04-07 Eli Zaretskii <eliz@gnu.org> 82012-04-07 Eli Zaretskii <eliz@gnu.org>
2 9
3 * makefile.w32-in (obj): Add xml.o. 10 * makefile.w32-in (obj): Add xml.o.
diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in
index cc1757e4e3b..6732030a648 100644
--- a/lib-src/Makefile.in
+++ b/lib-src/Makefile.in
@@ -36,8 +36,9 @@ configuration=@configuration@
36EXEEXT=@EXEEXT@ 36EXEEXT=@EXEEXT@
37C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@ 37C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@
38C_SWITCH_MACHINE=@C_SWITCH_MACHINE@ 38C_SWITCH_MACHINE=@C_SWITCH_MACHINE@
39C_WARNINGS_SWITCH = @C_WARNINGS_SWITCH@
40PROFILING_CFLAGS = @PROFILING_CFLAGS@ 39PROFILING_CFLAGS = @PROFILING_CFLAGS@
40WARN_CFLAGS = @WARN_CFLAGS@
41WERROR_CFLAGS = @WERROR_CFLAGS@
41 42
42# Program name transformation. 43# Program name transformation.
43TRANSFORM = @program_transform_name@ 44TRANSFORM = @program_transform_name@
@@ -167,7 +168,8 @@ LIBS_SYSTEM = @LIBS_SYSTEM@
167# Those files shared with other GNU utilities need HAVE_CONFIG_H 168# Those files shared with other GNU utilities need HAVE_CONFIG_H
168# defined before they know they can take advantage of the information 169# defined before they know they can take advantage of the information
169# in ../src/config.h. 170# in ../src/config.h.
170BASE_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) ${C_WARNINGS_SWITCH} \ 171BASE_CFLAGS = $(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) \
172 $(WARN_CFLAGS) $(WERROR_CFLAGS) \
171 -DHAVE_CONFIG_H -I. -I../src -I../lib \ 173 -DHAVE_CONFIG_H -I. -I../src -I../lib \
172 -I${srcdir} -I${srcdir}/../src -I${srcdir}/../lib 174 -I${srcdir} -I${srcdir}/../src -I${srcdir}/../lib
173 175
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 220ba713d4e..716510aff92 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -4,6 +4,7 @@ MOSTLYCLEANDIRS =
4MOSTLYCLEANFILES = 4MOSTLYCLEANFILES =
5noinst_LIBRARIES = 5noinst_LIBRARIES =
6 6
7AM_CFLAGS = $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS)
7DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src 8DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src
8 9
9include gnulib.mk 10include gnulib.mk
diff --git a/lwlib/ChangeLog b/lwlib/ChangeLog
index a4bb243f35d..f4800bc4bb0 100644
--- a/lwlib/ChangeLog
+++ b/lwlib/ChangeLog
@@ -1,3 +1,10 @@
12012-04-09 Paul Eggert <eggert@cs.ucla.edu>
2
3 configure: new option --enable-gcc-warnings
4 * Makefile.in (C_WARNINGS_SWITCH): Remove.
5 (WARN_CFLAGS, WERROR_CFLAGS): New macros.
6 (ALL_CFLAGS): Use new macros rather than old.
7
12011-10-13 Dmitry Antipov <dmantipov@yandex.ru> 82011-10-13 Dmitry Antipov <dmantipov@yandex.ru>
2 9
3 * lwlib-Xaw.c (openFont, xaw_destroy_instance): Replace free with 10 * lwlib-Xaw.c (openFont, xaw_destroy_instance): Replace free with
diff --git a/lwlib/Makefile.in b/lwlib/Makefile.in
index db108862d70..76507ac4b24 100644
--- a/lwlib/Makefile.in
+++ b/lwlib/Makefile.in
@@ -29,8 +29,9 @@ C_SWITCH_X_SITE=@C_SWITCH_X_SITE@
29C_SWITCH_X_SYSTEM=@C_SWITCH_X_SYSTEM@ 29C_SWITCH_X_SYSTEM=@C_SWITCH_X_SYSTEM@
30C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@ 30C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@
31C_SWITCH_MACHINE=@C_SWITCH_MACHINE@ 31C_SWITCH_MACHINE=@C_SWITCH_MACHINE@
32C_WARNINGS_SWITCH = @C_WARNINGS_SWITCH@
33PROFILING_CFLAGS = @PROFILING_CFLAGS@ 32PROFILING_CFLAGS = @PROFILING_CFLAGS@
33WARN_CFLAGS = `echo @WARN_CFLAGS@ | sed 's/ -Wwrite-strings//'`
34WERROR_CFLAGS = @WERROR_CFLAGS@
34 35
35CC=@CC@ 36CC=@CC@
36CFLAGS=@CFLAGS@ 37CFLAGS=@CFLAGS@
@@ -54,7 +55,8 @@ OBJS = lwlib.o $(TOOLKIT_OBJS) lwlib-utils.o
54## There are no generated lwlib files, hence no need for -I. 55## There are no generated lwlib files, hence no need for -I.
55ALL_CFLAGS= $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \ 56ALL_CFLAGS= $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \
56 $(C_SWITCH_X_SYSTEM) $(C_SWITCH_MACHINE) \ 57 $(C_SWITCH_X_SYSTEM) $(C_SWITCH_MACHINE) \
57 $(C_WARNINGS_SWITCH) $(PROFILING_CFLAGS) $(CFLAGS) \ 58 $(WARN_CFLAGS) $(WERROR_CFLAGS) \
59 $(PROFILING_CFLAGS) $(CFLAGS) \
58 -DHAVE_CONFIG_H -Demacs -I../src \ 60 -DHAVE_CONFIG_H -Demacs -I../src \
59 -I$(srcdir) -I$(srcdir)/../src -I../lib -I$(srcdir)/../lib 61 -I$(srcdir) -I$(srcdir)/../src -I../lib -I$(srcdir)/../lib
60 62
diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
new file mode 100644
index 00000000000..fd0e3722d35
--- /dev/null
+++ b/m4/manywarnings.m4
@@ -0,0 +1,184 @@
1# manywarnings.m4 serial 3
2dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Simon Josefsson
8
9# gl_MANYWARN_COMPLEMENT(OUTVAR, LISTVAR, REMOVEVAR)
10# --------------------------------------------------
11# Copy LISTVAR to OUTVAR except for the entries in REMOVEVAR.
12# Elements separated by whitespace. In set logic terms, the function
13# does OUTVAR = LISTVAR \ REMOVEVAR.
14AC_DEFUN([gl_MANYWARN_COMPLEMENT],
15[
16 gl_warn_set=
17 set x $2; shift
18 for gl_warn_item
19 do
20 case " $3 " in
21 *" $gl_warn_item "*)
22 ;;
23 *)
24 gl_warn_set="$gl_warn_set $gl_warn_item"
25 ;;
26 esac
27 done
28 $1=$gl_warn_set
29])
30
31# gl_MANYWARN_ALL_GCC(VARIABLE)
32# -----------------------------
33# Add all documented GCC warning parameters to variable VARIABLE.
34# Note that you need to test them using gl_WARN_ADD if you want to
35# make sure your gcc understands it.
36AC_DEFUN([gl_MANYWARN_ALL_GCC],
37[
38 dnl First, check if -Wno-missing-field-initializers is needed.
39 dnl -Wmissing-field-initializers is implied by -W, but that issues
40 dnl warnings with GCC version before 4.7, for the common idiom
41 dnl of initializing types on the stack to zero, using { 0, }
42 AC_REQUIRE([AC_PROG_CC])
43 if test -n "$GCC"; then
44
45 dnl First, check -W -Werror -Wno-missing-field-initializers is supported
46 dnl with the current $CC $CFLAGS $CPPFLAGS.
47 AC_MSG_CHECKING([whether -Wno-missing-field-initializers is supported])
48 AC_CACHE_VAL([gl_cv_cc_nomfi_supported], [
49 gl_save_CFLAGS="$CFLAGS"
50 CFLAGS="$CFLAGS -W -Werror -Wno-missing-field-initializers"
51 AC_COMPILE_IFELSE(
52 [AC_LANG_PROGRAM([[]], [[]])],
53 [gl_cv_cc_nomfi_supported=yes],
54 [gl_cv_cc_nomfi_supported=no])
55 CFLAGS="$gl_save_CFLAGS"])
56 AC_MSG_RESULT([$gl_cv_cc_nomfi_supported])
57
58 if test "$gl_cv_cc_nomfi_supported" = yes; then
59 dnl Now check whether -Wno-missing-field-initializers is needed
60 dnl for the { 0, } construct.
61 AC_MSG_CHECKING([whether -Wno-missing-field-initializers is needed])
62 AC_CACHE_VAL([gl_cv_cc_nomfi_needed], [
63 gl_save_CFLAGS="$CFLAGS"
64 CFLAGS="$CFLAGS -W -Werror"
65 AC_COMPILE_IFELSE(
66 [AC_LANG_PROGRAM(
67 [[void f (void)
68 {
69 typedef struct { int a; int b; } s_t;
70 s_t s1 = { 0, };
71 }
72 ]],
73 [[]])],
74 [gl_cv_cc_nomfi_needed=no],
75 [gl_cv_cc_nomfi_needed=yes])
76 CFLAGS="$gl_save_CFLAGS"
77 ])
78 AC_MSG_RESULT([$gl_cv_cc_nomfi_needed])
79 fi
80 fi
81
82 gl_manywarn_set=
83 for gl_manywarn_item in \
84 -Wall \
85 -W \
86 -Wformat-y2k \
87 -Wformat-nonliteral \
88 -Wformat-security \
89 -Winit-self \
90 -Wmissing-include-dirs \
91 -Wswitch-default \
92 -Wswitch-enum \
93 -Wunused \
94 -Wunknown-pragmas \
95 -Wstrict-aliasing \
96 -Wstrict-overflow \
97 -Wsystem-headers \
98 -Wfloat-equal \
99 -Wtraditional \
100 -Wtraditional-conversion \
101 -Wdeclaration-after-statement \
102 -Wundef \
103 -Wshadow \
104 -Wunsafe-loop-optimizations \
105 -Wpointer-arith \
106 -Wbad-function-cast \
107 -Wc++-compat \
108 -Wcast-qual \
109 -Wcast-align \
110 -Wwrite-strings \
111 -Wconversion \
112 -Wsign-conversion \
113 -Wlogical-op \
114 -Waggregate-return \
115 -Wstrict-prototypes \
116 -Wold-style-definition \
117 -Wmissing-prototypes \
118 -Wmissing-declarations \
119 -Wmissing-noreturn \
120 -Wmissing-format-attribute \
121 -Wpacked \
122 -Wpadded \
123 -Wredundant-decls \
124 -Wnested-externs \
125 -Wunreachable-code \
126 -Winline \
127 -Winvalid-pch \
128 -Wlong-long \
129 -Wvla \
130 -Wvolatile-register-var \
131 -Wdisabled-optimization \
132 -Wstack-protector \
133 -Woverlength-strings \
134 -Wbuiltin-macro-redefined \
135 -Wmudflap \
136 -Wpacked-bitfield-compat \
137 -Wsync-nand \
138 ; do
139 gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
140 done
141 # The following are not documented in the manual but are included in
142 # output from gcc --help=warnings.
143 for gl_manywarn_item in \
144 -Wattributes \
145 -Wcoverage-mismatch \
146 -Wmultichar \
147 -Wunused-macros \
148 ; do
149 gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
150 done
151 # More warnings from gcc 4.6.2 --help=warnings.
152 for gl_manywarn_item in \
153 -Wabi \
154 -Wcpp \
155 -Wdeprecated \
156 -Wdeprecated-declarations \
157 -Wdiv-by-zero \
158 -Wdouble-promotion \
159 -Wendif-labels \
160 -Wextra \
161 -Wformat-contains-nul \
162 -Wformat-extra-args \
163 -Wformat-zero-length \
164 -Wformat=2 \
165 -Wmultichar \
166 -Wnormalized=nfc \
167 -Woverflow \
168 -Wpointer-to-int-cast \
169 -Wpragmas \
170 -Wsuggest-attribute=const \
171 -Wsuggest-attribute=noreturn \
172 -Wsuggest-attribute=pure \
173 -Wtrampolines \
174 ; do
175 gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
176 done
177
178 # Disable the missing-field-initializers warning if needed
179 if test "$gl_cv_cc_nomfi_needed" = yes; then
180 gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers"
181 fi
182
183 $1=$gl_manywarn_set
184])
diff --git a/m4/warnings.m4 b/m4/warnings.m4
new file mode 100644
index 00000000000..c14c4801e78
--- /dev/null
+++ b/m4/warnings.m4
@@ -0,0 +1,42 @@
1# warnings.m4 serial 6
2dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Simon Josefsson
8
9# gl_AS_VAR_APPEND(VAR, VALUE)
10# ----------------------------
11# Provide the functionality of AS_VAR_APPEND if Autoconf does not have it.
12m4_ifdef([AS_VAR_APPEND],
13[m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])],
14[m4_define([gl_AS_VAR_APPEND],
15[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
16
17
18# gl_WARN_ADD(PARAMETER, [VARIABLE = WARN_CFLAGS])
19# ------------------------------------------------
20# Adds parameter to WARN_CFLAGS if the compiler supports it. For example,
21# gl_WARN_ADD([-Wparentheses]).
22#
23# If VARIABLE is a variable name, AC_SUBST it.
24AC_DEFUN([gl_WARN_ADD],
25dnl FIXME: gl_Warn must be used unquoted until we can assume
26dnl autoconf 2.64 or newer.
27[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl
28AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl
29AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [
30 gl_save_compiler_FLAGS="$gl_Flags"
31 gl_Flags="$gl_Flags $1"
32 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
33 [AS_VAR_SET(gl_Warn, [yes])],
34 [AS_VAR_SET(gl_Warn, [no])])
35 gl_Flags="$gl_save_compiler_FLAGS"
36])
37AS_VAR_IF(gl_Warn, [yes],
38 [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])])
39AS_VAR_POPDEF([gl_Flags])dnl
40AS_VAR_POPDEF([gl_Warn])dnl
41m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl
42])
diff --git a/oldXMenu/ChangeLog b/oldXMenu/ChangeLog
index 1d3091c6bb4..f5d65b49671 100644
--- a/oldXMenu/ChangeLog
+++ b/oldXMenu/ChangeLog
@@ -1,3 +1,10 @@
12012-04-09 Paul Eggert <eggert@cs.ucla.edu>
2
3 configure: new option --enable-gcc-warnings
4 * Makefile.in (C_WARNINGS_SWITCH): Remove.
5 (WARN_CFLAGS, WERROR_CFLAGS): New macros.
6 (ALL_CFLAGS): Use new macros rather than old.
7
12011-04-16 Paul Eggert <eggert@cs.ucla.edu> 82011-04-16 Paul Eggert <eggert@cs.ucla.edu>
2 9
3 Static checks with GCC 4.6.0 and non-default toolkits. 10 Static checks with GCC 4.6.0 and non-default toolkits.
diff --git a/oldXMenu/Makefile.in b/oldXMenu/Makefile.in
index 94c49fb9966..e7bc402cb0d 100644
--- a/oldXMenu/Makefile.in
+++ b/oldXMenu/Makefile.in
@@ -48,8 +48,9 @@ C_SWITCH_X_SITE=@C_SWITCH_X_SITE@
48C_SWITCH_X_SYSTEM=@C_SWITCH_X_SYSTEM@ 48C_SWITCH_X_SYSTEM=@C_SWITCH_X_SYSTEM@
49C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@ 49C_SWITCH_SYSTEM=@C_SWITCH_SYSTEM@
50C_SWITCH_MACHINE=@C_SWITCH_MACHINE@ 50C_SWITCH_MACHINE=@C_SWITCH_MACHINE@
51C_WARNINGS_SWITCH = @C_WARNINGS_SWITCH@
52PROFILING_CFLAGS = @PROFILING_CFLAGS@ 51PROFILING_CFLAGS = @PROFILING_CFLAGS@
52WARN_CFLAGS = @WARN_CFLAGS@
53WERROR_CFLAGS = @WERROR_CFLAGS@
53 54
54EXTRA=insque.o 55EXTRA=insque.o
55CC=@CC@ 56CC=@CC@
@@ -89,7 +90,7 @@ all:: libXMenu11.a
89 90
90ALL_CFLAGS=$(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) \ 91ALL_CFLAGS=$(C_SWITCH_SYSTEM) $(C_SWITCH_MACHINE) \
91 $(C_SWITCH_X_SITE) $(C_SWITCH_X_SYSTEM) \ 92 $(C_SWITCH_X_SITE) $(C_SWITCH_X_SYSTEM) \
92 ${C_WARNINGS_SWITCH} ${PROFILING_CFLAGS} \ 93 $(WARN_CFLAGS) $(WERROR_CFLAGS) ${C_WARNINGS_SWITCH} ${PROFILING_CFLAGS} \
93 $(CPPFLAGS) $(CFLAGS) -DEMACS_BITMAP_FILES \ 94 $(CPPFLAGS) $(CFLAGS) -DEMACS_BITMAP_FILES \
94 -I../src -I${srcdir} -I${srcdir}/../src 95 -I../src -I${srcdir} -I${srcdir}/../src
95 96
diff --git a/src/ChangeLog b/src/ChangeLog
index dbff8e35492..df3336b52e1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,18 @@
12012-04-09 Paul Eggert <eggert@cs.ucla.edu> 12012-04-09 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 configure: new option --enable-gcc-warnings
4 * Makefile.in (C_WARNINGS_SWITCH): Remove.
5 (WARN_CFLAGS, WERROR_CFLAGS): New macros.
6 (ALL_CFLAGS): Use new macros rather than old.
7 * process.c: Ignore -Wstrict-overflow to work around GCC bug 52904.
8 * regex.c: Ignore -Wstrict-overflow. If !emacs, also ignore
9 -Wunused-but-set-variable, -Wunused-function, -Wunused-macros,
10 -Wunused-result, -Wunused-variable. This should go away once
11 the Emacs and Gnulib regex code is merged.
12 (xmalloc, xrealloc): Now static.
13
142012-04-09 Paul Eggert <eggert@cs.ucla.edu>
15
3 composite.c: use 'double' consistently 16 composite.c: use 'double' consistently
4 * composite.c (get_composition_id): Use 'double' consistently 17 * composite.c (get_composition_id): Use 'double' consistently
5 instead of converting 'float' to 'double' and vice versa; this is 18 instead of converting 'float' to 'double' and vice versa; this is
diff --git a/src/Makefile.in b/src/Makefile.in
index 8c3704f830e..19f586396cb 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -68,7 +68,8 @@ OTHER_FILES = @OTHER_FILES@
68PROFILING_CFLAGS = @PROFILING_CFLAGS@ 68PROFILING_CFLAGS = @PROFILING_CFLAGS@
69 69
70## Flags to pass to the compiler to enable build warnings 70## Flags to pass to the compiler to enable build warnings
71C_WARNINGS_SWITCH = @C_WARNINGS_SWITCH@ 71WARN_CFLAGS = @WARN_CFLAGS@
72WERROR_CFLAGS = @WERROR_CFLAGS@
72 73
73## Machine-specific CFLAGS. 74## Machine-specific CFLAGS.
74C_SWITCH_MACHINE=@C_SWITCH_MACHINE@ 75C_SWITCH_MACHINE=@C_SWITCH_MACHINE@
@@ -314,7 +315,7 @@ ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I$(srcdir) \
314 $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \ 315 $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \
315 $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) $(PROFILING_CFLAGS) \ 316 $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) $(PROFILING_CFLAGS) \
316 $(LIBGNUTLS_CFLAGS) \ 317 $(LIBGNUTLS_CFLAGS) \
317 $(C_WARNINGS_SWITCH) $(CFLAGS) 318 $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAGS)
318ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS) 319ALL_OBJC_CFLAGS=$(ALL_CFLAGS) $(GNU_OBJC_CFLAGS)
319 320
320.SUFFIXES: .m 321.SUFFIXES: .m
diff --git a/src/process.c b/src/process.c
index f2f33a9eafc..f14de474ee0 100644
--- a/src/process.c
+++ b/src/process.c
@@ -120,6 +120,13 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
120#include "nsterm.h" 120#include "nsterm.h"
121#endif 121#endif
122 122
123/* Work around GCC 4.7.0 bug with strict overflow checking; see
124 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
125 These lines can be removed once the GCC bug is fixed. */
126#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
127# pragma GCC diagnostic ignored "-Wstrict-overflow"
128#endif
129
123Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid; 130Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
124Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime; 131Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
125Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs; 132Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
diff --git a/src/regex.c b/src/regex.c
index 0f9150193ec..d16a5148054 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -33,6 +33,19 @@
33 #pragma alloca 33 #pragma alloca
34#endif 34#endif
35 35
36/* Ignore some GCC warnings for now. This section should go away
37 once the Emacs and Gnulib regex code is merged. */
38#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
39# pragma GCC diagnostic ignored "-Wstrict-overflow"
40# ifndef emacs
41# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
42# pragma GCC diagnostic ignored "-Wunused-function"
43# pragma GCC diagnostic ignored "-Wunused-macros"
44# pragma GCC diagnostic ignored "-Wunused-result"
45# pragma GCC diagnostic ignored "-Wunused-variable"
46# endif
47#endif
48
36#ifdef HAVE_CONFIG_H 49#ifdef HAVE_CONFIG_H
37# include <config.h> 50# include <config.h>
38#endif 51#endif
@@ -198,7 +211,7 @@
198 211
199/* When used in Emacs's lib-src, we need xmalloc and xrealloc. */ 212/* When used in Emacs's lib-src, we need xmalloc and xrealloc. */
200 213
201void * 214static void *
202xmalloc (size_t size) 215xmalloc (size_t size)
203{ 216{
204 register void *val; 217 register void *val;
@@ -211,7 +224,7 @@ xmalloc (size_t size)
211 return val; 224 return val;
212} 225}
213 226
214void * 227static void *
215xrealloc (void *block, size_t size) 228xrealloc (void *block, size_t size)
216{ 229{
217 register void *val; 230 register void *val;