diff options
| author | Paul Eggert | 2012-04-09 00:45:59 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-04-09 00:45:59 -0700 |
| commit | b8df54ffbefc5ddf40ddcda68a2a682769c5833d (patch) | |
| tree | 95b4e71a64030550e3c1719575121e773167d53a /m4 | |
| parent | cb3c2e3eca8bf31ac861739272ba1e182f4ec295 (diff) | |
| download | emacs-b8df54ffbefc5ddf40ddcda68a2a682769c5833d.tar.gz emacs-b8df54ffbefc5ddf40ddcda68a2a682769c5833d.zip | |
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.
* 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.
* 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.
Diffstat (limited to 'm4')
| -rw-r--r-- | m4/manywarnings.m4 | 184 | ||||
| -rw-r--r-- | m4/warnings.m4 | 42 |
2 files changed, 226 insertions, 0 deletions
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 | ||
| 2 | dnl Copyright (C) 2008-2012 Free Software Foundation, Inc. | ||
| 3 | dnl This file is free software; the Free Software Foundation | ||
| 4 | dnl gives unlimited permission to copy and/or distribute it, | ||
| 5 | dnl with or without modifications, as long as this notice is preserved. | ||
| 6 | |||
| 7 | dnl 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. | ||
| 14 | AC_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. | ||
| 36 | AC_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 | ||
| 2 | dnl Copyright (C) 2008-2012 Free Software Foundation, Inc. | ||
| 3 | dnl This file is free software; the Free Software Foundation | ||
| 4 | dnl gives unlimited permission to copy and/or distribute it, | ||
| 5 | dnl with or without modifications, as long as this notice is preserved. | ||
| 6 | |||
| 7 | dnl 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. | ||
| 12 | m4_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. | ||
| 24 | AC_DEFUN([gl_WARN_ADD], | ||
| 25 | dnl FIXME: gl_Warn must be used unquoted until we can assume | ||
| 26 | dnl autoconf 2.64 or newer. | ||
| 27 | [AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl | ||
| 28 | AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl | ||
| 29 | AC_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 | ]) | ||
| 37 | AS_VAR_IF(gl_Warn, [yes], | ||
| 38 | [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])]) | ||
| 39 | AS_VAR_POPDEF([gl_Flags])dnl | ||
| 40 | AS_VAR_POPDEF([gl_Warn])dnl | ||
| 41 | m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl | ||
| 42 | ]) | ||