declare smobs in alloc.c
[bpt/emacs.git] / m4 / manywarnings.m4
CommitLineData
959c3d24 1# manywarnings.m4 serial 6
ba318903 2dnl Copyright (C) 2008-2014 Free Software Foundation, Inc.
b8df54ff
PE
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[
bb1dfdad
PE
38 dnl First, check for some issues that only occur when combining multiple
39 dnl gcc warning categories.
b8df54ff
PE
40 AC_REQUIRE([AC_PROG_CC])
41 if test -n "$GCC"; then
42
bb1dfdad 43 dnl Check if -W -Werror -Wno-missing-field-initializers is supported
b8df54ff
PE
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])
55
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
bb1dfdad
PE
78
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])
92
b8df54ff
PE
93 fi
94
bb1dfdad 95 # List all gcc warning categories.
b8df54ff
PE
96 gl_manywarn_set=
97 for gl_manywarn_item in \
b8df54ff 98 -W \
7f507777
PE
99 -Wabi \
100 -Waddress \
cdd0de4b 101 -Waggressive-loop-optimizations \
7f507777
PE
102 -Wall \
103 -Warray-bounds \
104 -Wattributes \
b8df54ff 105 -Wbad-function-cast \
b8df54ff 106 -Wbuiltin-macro-redefined \
7f507777
PE
107 -Wcast-align \
108 -Wchar-subscripts \
109 -Wclobbered \
110 -Wcomment \
111 -Wcomments \
b8df54ff 112 -Wcoverage-mismatch \
b8df54ff
PE
113 -Wcpp \
114 -Wdeprecated \
115 -Wdeprecated-declarations \
7f507777 116 -Wdisabled-optimization \
b8df54ff
PE
117 -Wdiv-by-zero \
118 -Wdouble-promotion \
7f507777 119 -Wempty-body \
b8df54ff 120 -Wendif-labels \
7f507777 121 -Wenum-compare \
b8df54ff
PE
122 -Wextra \
123 -Wformat-contains-nul \
124 -Wformat-extra-args \
7f507777
PE
125 -Wformat-nonliteral \
126 -Wformat-security \
127 -Wformat-y2k \
b8df54ff 128 -Wformat-zero-length \
7f507777
PE
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 \
7f507777 146 -Wmissing-include-dirs \
7f507777
PE
147 -Wmissing-parameter-type \
148 -Wmissing-prototypes \
b8df54ff 149 -Wmultichar \
7f507777
PE
150 -Wnarrowing \
151 -Wnested-externs \
152 -Wnonnull \
b8df54ff 153 -Wnormalized=nfc \
7f507777
PE
154 -Wold-style-declaration \
155 -Wold-style-definition \
b8df54ff 156 -Woverflow \
7f507777
PE
157 -Woverlength-strings \
158 -Woverride-init \
159 -Wpacked \
160 -Wpacked-bitfield-compat \
161 -Wparentheses \
162 -Wpointer-arith \
163 -Wpointer-sign \
b8df54ff
PE
164 -Wpointer-to-int-cast \
165 -Wpragmas \
cdd0de4b 166 -Wreturn-local-addr \
7f507777
PE
167 -Wreturn-type \
168 -Wsequence-point \
169 -Wshadow \
170 -Wsizeof-pointer-memaccess \
171 -Wstack-protector \
172 -Wstrict-aliasing \
173 -Wstrict-overflow \
174 -Wstrict-prototypes \
b8df54ff 175 -Wsuggest-attribute=const \
7f507777 176 -Wsuggest-attribute=format \
b8df54ff
PE
177 -Wsuggest-attribute=noreturn \
178 -Wsuggest-attribute=pure \
7f507777
PE
179 -Wswitch \
180 -Wswitch-default \
181 -Wsync-nand \
182 -Wsystem-headers \
b8df54ff 183 -Wtrampolines \
7f507777
PE
184 -Wtrigraphs \
185 -Wtype-limits \
186 -Wuninitialized \
187 -Wunknown-pragmas \
7f507777
PE
188 -Wunsafe-loop-optimizations \
189 -Wunused \
190 -Wunused-but-set-parameter \
191 -Wunused-but-set-variable \
192 -Wunused-function \
193 -Wunused-label \
194 -Wunused-local-typedefs \
195 -Wunused-macros \
196 -Wunused-parameter \
197 -Wunused-result \
198 -Wunused-value \
199 -Wunused-variable \
200 -Wvarargs \
201 -Wvariadic-macros \
202 -Wvector-operation-performance \
203 -Wvla \
204 -Wvolatile-register-var \
205 -Wwrite-strings \
959c3d24
PE
206 -fdiagnostics-show-option \
207 -funit-at-a-time \
7f507777 208 \
b8df54ff
PE
209 ; do
210 gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
211 done
212
bb1dfdad 213 # Disable specific options as needed.
b8df54ff
PE
214 if test "$gl_cv_cc_nomfi_needed" = yes; then
215 gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers"
216 fi
217
bb1dfdad
PE
218 if test "$gl_cv_cc_uninitialized_supported" = no; then
219 gl_manywarn_set="$gl_manywarn_set -Wno-uninitialized"
220 fi
221
b8df54ff
PE
222 $1=$gl_manywarn_set
223])