* src/casefiddle.c (casify_word): Return Qnil.
[emacs.git] / m4 / manywarnings.m4
blob89fd0ae38e387b9451fb62cb37936ccaefff3686
1 # manywarnings.m4 serial 8
2 dnl Copyright (C) 2008-2016 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],
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
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 for some issues that only occur when combining multiple
39   dnl gcc warning categories.
40   AC_REQUIRE([AC_PROG_CC])
41   if test -n "$GCC"; then
43     dnl Check if -W -Werror -Wno-missing-field-initializers is supported
44     dnl with the current $CC $CFLAGS $CPPFLAGS.
45     AC_MSG_CHECKING([whether -Wno-missing-field-initializers is supported])
46     AC_CACHE_VAL([gl_cv_cc_nomfi_supported], [
47       gl_save_CFLAGS="$CFLAGS"
48       CFLAGS="$CFLAGS -W -Werror -Wno-missing-field-initializers"
49       AC_COMPILE_IFELSE(
50         [AC_LANG_PROGRAM([[]], [[]])],
51         [gl_cv_cc_nomfi_supported=yes],
52         [gl_cv_cc_nomfi_supported=no])
53       CFLAGS="$gl_save_CFLAGS"])
54     AC_MSG_RESULT([$gl_cv_cc_nomfi_supported])
56     if test "$gl_cv_cc_nomfi_supported" = yes; then
57       dnl Now check whether -Wno-missing-field-initializers is needed
58       dnl for the { 0, } construct.
59       AC_MSG_CHECKING([whether -Wno-missing-field-initializers is needed])
60       AC_CACHE_VAL([gl_cv_cc_nomfi_needed], [
61         gl_save_CFLAGS="$CFLAGS"
62         CFLAGS="$CFLAGS -W -Werror"
63         AC_COMPILE_IFELSE(
64           [AC_LANG_PROGRAM(
65              [[void f (void)
66                {
67                  typedef struct { int a; int b; } s_t;
68                  s_t s1 = { 0, };
69                }
70              ]],
71              [[]])],
72           [gl_cv_cc_nomfi_needed=no],
73           [gl_cv_cc_nomfi_needed=yes])
74         CFLAGS="$gl_save_CFLAGS"
75       ])
76       AC_MSG_RESULT([$gl_cv_cc_nomfi_needed])
77     fi
79     dnl Next, check if -Werror -Wuninitialized is useful with the
80     dnl user's choice of $CFLAGS; some versions of gcc warn that it
81     dnl has no effect if -O is not also used
82     AC_MSG_CHECKING([whether -Wuninitialized is supported])
83     AC_CACHE_VAL([gl_cv_cc_uninitialized_supported], [
84       gl_save_CFLAGS="$CFLAGS"
85       CFLAGS="$CFLAGS -Werror -Wuninitialized"
86       AC_COMPILE_IFELSE(
87         [AC_LANG_PROGRAM([[]], [[]])],
88         [gl_cv_cc_uninitialized_supported=yes],
89         [gl_cv_cc_uninitialized_supported=no])
90       CFLAGS="$gl_save_CFLAGS"])
91     AC_MSG_RESULT([$gl_cv_cc_uninitialized_supported])
93   fi
95   # List all gcc warning categories.
96   # To compare this list to your installed GCC's, run this Bash command:
97   #
98   # comm -3 \
99   #  <(sed -n 's/^  *\(-[^ ]*\) .*/\1/p' manywarnings.m4 | sort) \
100   #  <(gcc --help=warnings | sed -n 's/^  \(-[^ ]*\) .*/\1/p' | sort |
101   #      grep -v -x -f <(
102   #         awk '/^[^#]/ {print $1}' ../build-aux/gcc-warning.spec))
104   gl_manywarn_set=
105   for gl_manywarn_item in \
106     -fno-common \
107     -W \
108     -Wabi \
109     -Waddress \
110     -Waggressive-loop-optimizations \
111     -Wall \
112     -Wattributes \
113     -Wbad-function-cast \
114     -Wbool-compare \
115     -Wbuiltin-macro-redefined \
116     -Wcast-align \
117     -Wchar-subscripts \
118     -Wchkp \
119     -Wclobbered \
120     -Wcomment \
121     -Wcomments \
122     -Wcoverage-mismatch \
123     -Wcpp \
124     -Wdate-time \
125     -Wdeprecated \
126     -Wdeprecated-declarations \
127     -Wdesignated-init \
128     -Wdisabled-optimization \
129     -Wdiscarded-array-qualifiers \
130     -Wdiscarded-qualifiers \
131     -Wdiv-by-zero \
132     -Wdouble-promotion \
133     -Wduplicated-cond \
134     -Wempty-body \
135     -Wendif-labels \
136     -Wenum-compare \
137     -Wextra \
138     -Wformat-contains-nul \
139     -Wformat-extra-args \
140     -Wformat-nonliteral \
141     -Wformat-security \
142     -Wformat-signedness \
143     -Wformat-y2k \
144     -Wformat-zero-length \
145     -Wframe-address \
146     -Wfree-nonheap-object \
147     -Whsa \
148     -Wignored-attributes \
149     -Wignored-qualifiers \
150     -Wimplicit \
151     -Wimplicit-function-declaration \
152     -Wimplicit-int \
153     -Wincompatible-pointer-types \
154     -Winit-self \
155     -Winline \
156     -Wint-conversion \
157     -Wint-to-pointer-cast \
158     -Winvalid-memory-model \
159     -Winvalid-pch \
160     -Wjump-misses-init \
161     -Wlogical-not-parentheses \
162     -Wlogical-op \
163     -Wmain \
164     -Wmaybe-uninitialized \
165     -Wmemset-transposed-args \
166     -Wmisleading-indentation \
167     -Wmissing-braces \
168     -Wmissing-declarations \
169     -Wmissing-field-initializers \
170     -Wmissing-include-dirs \
171     -Wmissing-parameter-type \
172     -Wmissing-prototypes \
173     -Wmultichar \
174     -Wnarrowing \
175     -Wnested-externs \
176     -Wnonnull \
177     -Wnonnull-compare \
178     -Wnull-dereference \
179     -Wodr \
180     -Wold-style-declaration \
181     -Wold-style-definition \
182     -Wopenmp-simd \
183     -Woverflow \
184     -Woverlength-strings \
185     -Woverride-init \
186     -Wpacked \
187     -Wpacked-bitfield-compat \
188     -Wparentheses \
189     -Wpointer-arith \
190     -Wpointer-sign \
191     -Wpointer-to-int-cast \
192     -Wpragmas \
193     -Wreturn-local-addr \
194     -Wreturn-type \
195     -Wscalar-storage-order \
196     -Wsequence-point \
197     -Wshadow \
198     -Wshift-count-negative \
199     -Wshift-count-overflow \
200     -Wshift-negative-value \
201     -Wsizeof-array-argument \
202     -Wsizeof-pointer-memaccess \
203     -Wstack-protector \
204     -Wstrict-aliasing \
205     -Wstrict-overflow \
206     -Wstrict-prototypes \
207     -Wsuggest-attribute=const \
208     -Wsuggest-attribute=format \
209     -Wsuggest-attribute=noreturn \
210     -Wsuggest-attribute=pure \
211     -Wsuggest-final-methods \
212     -Wsuggest-final-types \
213     -Wswitch \
214     -Wswitch-bool \
215     -Wswitch-default \
216     -Wsync-nand \
217     -Wsystem-headers \
218     -Wtautological-compare \
219     -Wtrampolines \
220     -Wtrigraphs \
221     -Wtype-limits \
222     -Wuninitialized \
223     -Wunknown-pragmas \
224     -Wunsafe-loop-optimizations \
225     -Wunused \
226     -Wunused-but-set-parameter \
227     -Wunused-but-set-variable \
228     -Wunused-function \
229     -Wunused-label \
230     -Wunused-local-typedefs \
231     -Wunused-macros \
232     -Wunused-parameter \
233     -Wunused-result \
234     -Wunused-value \
235     -Wunused-variable \
236     -Wvarargs \
237     -Wvariadic-macros \
238     -Wvector-operation-performance \
239     -Wvla \
240     -Wvolatile-register-var \
241     -Wwrite-strings \
242     \
243     ; do
244     gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
245   done
247   # gcc --help=warnings outputs an unusual form for these options; list
248   # them here so that the above 'comm' command doesn't report a false match.
249   gl_manywarn_set="$gl_manywarn_set -Warray-bounds=2"
250   gl_manywarn_set="$gl_manywarn_set -Wnormalized=nfc"
251   gl_manywarn_set="$gl_manywarn_set -Wshift-overflow=2"
252   gl_manywarn_set="$gl_manywarn_set -Wunused-const-variable=2"
254   # These are needed for older GCC versions.
255   if test -n "$GCC"; then
256     case `($CC --version) 2>/dev/null` in
257       'gcc (GCC) '[[0-3]].* | \
258       'gcc (GCC) '4.[[0-7]].*)
259         gl_manywarn_set="$gl_manywarn_set -fdiagnostics-show-option"
260         gl_manywarn_set="$gl_manywarn_set -funit-at-a-time"
261           ;;
262     esac
263   fi
265   # Disable specific options as needed.
266   if test "$gl_cv_cc_nomfi_needed" = yes; then
267     gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers"
268   fi
270   if test "$gl_cv_cc_uninitialized_supported" = no; then
271     gl_manywarn_set="$gl_manywarn_set -Wno-uninitialized"
272   fi
274   $1=$gl_manywarn_set