* emacs-lisp/trace.el (trace-function, trace-function-background): Doc fix.
[emacs.git] / m4 / manywarnings.m4
blob45a30afda70ef37e2308b970f71652e846832ea9
1 # manywarnings.m4 serial 5
2 dnl Copyright (C) 2008-2013 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   gl_manywarn_set=
97   for gl_manywarn_item in \
98     -W \
99     -Wabi \
100     -Waddress \
101     -Wall \
102     -Warray-bounds \
103     -Wattributes \
104     -Wbad-function-cast \
105     -Wbuiltin-macro-redefined \
106     -Wcast-align \
107     -Wchar-subscripts \
108     -Wclobbered \
109     -Wcomment \
110     -Wcomments \
111     -Wcoverage-mismatch \
112     -Wcpp \
113     -Wdeprecated \
114     -Wdeprecated-declarations \
115     -Wdisabled-optimization \
116     -Wdiv-by-zero \
117     -Wdouble-promotion \
118     -Wempty-body \
119     -Wendif-labels \
120     -Wenum-compare \
121     -Wextra \
122     -Wformat-contains-nul \
123     -Wformat-extra-args \
124     -Wformat-nonliteral \
125     -Wformat-security \
126     -Wformat-y2k \
127     -Wformat-zero-length \
128     -Wformat=2 \
129     -Wfree-nonheap-object \
130     -Wignored-qualifiers \
131     -Wimplicit \
132     -Wimplicit-function-declaration \
133     -Wimplicit-int \
134     -Winit-self \
135     -Winline \
136     -Wint-to-pointer-cast \
137     -Winvalid-memory-model \
138     -Winvalid-pch \
139     -Wjump-misses-init \
140     -Wlogical-op \
141     -Wmain \
142     -Wmaybe-uninitialized \
143     -Wmissing-braces \
144     -Wmissing-declarations \
145     -Wmissing-field-initializers \
146     -Wmissing-format-attribute \
147     -Wmissing-include-dirs \
148     -Wmissing-noreturn \
149     -Wmissing-parameter-type \
150     -Wmissing-prototypes \
151     -Wmudflap \
152     -Wmultichar \
153     -Wnarrowing \
154     -Wnested-externs \
155     -Wnonnull \
156     -Wnormalized=nfc \
157     -Wold-style-declaration \
158     -Wold-style-definition \
159     -Woverflow \
160     -Woverlength-strings \
161     -Woverride-init \
162     -Wpacked \
163     -Wpacked-bitfield-compat \
164     -Wparentheses \
165     -Wpointer-arith \
166     -Wpointer-sign \
167     -Wpointer-to-int-cast \
168     -Wpragmas \
169     -Wreturn-type \
170     -Wsequence-point \
171     -Wshadow \
172     -Wsizeof-pointer-memaccess \
173     -Wstack-protector \
174     -Wstrict-aliasing \
175     -Wstrict-overflow \
176     -Wstrict-prototypes \
177     -Wsuggest-attribute=const \
178     -Wsuggest-attribute=format \
179     -Wsuggest-attribute=noreturn \
180     -Wsuggest-attribute=pure \
181     -Wswitch \
182     -Wswitch-default \
183     -Wsync-nand \
184     -Wsystem-headers \
185     -Wtrampolines \
186     -Wtrigraphs \
187     -Wtype-limits \
188     -Wuninitialized \
189     -Wunknown-pragmas \
190     -Wunreachable-code \
191     -Wunsafe-loop-optimizations \
192     -Wunused \
193     -Wunused-but-set-parameter \
194     -Wunused-but-set-variable \
195     -Wunused-function \
196     -Wunused-label \
197     -Wunused-local-typedefs \
198     -Wunused-macros \
199     -Wunused-parameter \
200     -Wunused-result \
201     -Wunused-value \
202     -Wunused-variable \
203     -Wvarargs \
204     -Wvariadic-macros \
205     -Wvector-operation-performance \
206     -Wvla \
207     -Wvolatile-register-var \
208     -Wwrite-strings \
209     \
210     ; do
211     gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
212   done
214   # Disable specific options as needed.
215   if test "$gl_cv_cc_nomfi_needed" = yes; then
216     gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers"
217   fi
219   if test "$gl_cv_cc_uninitialized_supported" = no; then
220     gl_manywarn_set="$gl_manywarn_set -Wno-uninitialized"
221   fi
223   $1=$gl_manywarn_set