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