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.
7 dnl From Simon Josefsson
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],
24 gl_warn_set="$gl_warn_set $gl_warn_item"
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],
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
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"
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])
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"
69 typedef struct { int a; int b; } s_t;
74 [gl_cv_cc_nomfi_needed=no],
75 [gl_cv_cc_nomfi_needed=yes])
76 CFLAGS="$gl_save_CFLAGS"
78 AC_MSG_RESULT([$gl_cv_cc_nomfi_needed])
83 for gl_manywarn_item in \
90 -Wmissing-include-dirs \
100 -Wtraditional-conversion \
101 -Wdeclaration-after-statement \
104 -Wunsafe-loop-optimizations \
106 -Wbad-function-cast \
115 -Wstrict-prototypes \
116 -Wold-style-definition \
117 -Wmissing-prototypes \
118 -Wmissing-declarations \
120 -Wmissing-format-attribute \
130 -Wvolatile-register-var \
131 -Wdisabled-optimization \
133 -Woverlength-strings \
134 -Wbuiltin-macro-redefined \
136 -Wpacked-bitfield-compat \
139 gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
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 \
145 -Wcoverage-mismatch \
149 gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
151 # More warnings from gcc 4.6.2 --help=warnings.
152 for gl_manywarn_item in \
156 -Wdeprecated-declarations \
161 -Wformat-contains-nul \
162 -Wformat-extra-args \
163 -Wformat-zero-length \
168 -Wpointer-to-int-cast \
170 -Wsuggest-attribute=const \
171 -Wsuggest-attribute=noreturn \
172 -Wsuggest-attribute=pure \
175 gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
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"