|
1 |
| -# manywarnings.m4 serial 3 |
2 |
| -dnl Copyright (C) 2008-2012 Free Software Foundation, Inc. |
| 1 | +# manywarnings.m4 serial 7 |
| 2 | +dnl Copyright (C) 2008-2014 Free Software Foundation, Inc. |
3 | 3 | dnl This file is free software; the Free Software Foundation
|
4 | 4 | dnl gives unlimited permission to copy and/or distribute it,
|
5 | 5 | dnl with or without modifications, as long as this notice is preserved.
|
@@ -35,14 +35,12 @@ AC_DEFUN([gl_MANYWARN_COMPLEMENT],
|
35 | 35 | # make sure your gcc understands it.
|
36 | 36 | AC_DEFUN([gl_MANYWARN_ALL_GCC],
|
37 | 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, } |
| 38 | + dnl First, check for some issues that only occur when combining multiple |
| 39 | + dnl gcc warning categories. |
42 | 40 | AC_REQUIRE([AC_PROG_CC])
|
43 | 41 | if test -n "$GCC"; then
|
44 | 42 |
|
45 |
| - dnl First, check -W -Werror -Wno-missing-field-initializers is supported |
| 43 | + dnl Check if -W -Werror -Wno-missing-field-initializers is supported |
46 | 44 | dnl with the current $CC $CFLAGS $CPPFLAGS.
|
47 | 45 | AC_MSG_CHECKING([whether -Wno-missing-field-initializers is supported])
|
48 | 46 | AC_CACHE_VAL([gl_cv_cc_nomfi_supported], [
|
@@ -77,108 +75,171 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
|
77 | 75 | ])
|
78 | 76 | AC_MSG_RESULT([$gl_cv_cc_nomfi_needed])
|
79 | 77 | fi
|
| 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 | +
|
80 | 93 | fi
|
81 | 94 |
|
| 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)) |
| 103 | +
|
82 | 104 | gl_manywarn_set=
|
83 | 105 | for gl_manywarn_item in \
|
84 |
| - -Wall \ |
85 | 106 | -W \
|
86 |
| - -Wformat-y2k \ |
87 |
| - -Wformat-nonliteral \ |
88 |
| - -Wformat-security \ |
89 |
| - -Winit-self \ |
90 |
| - -Wmissing-include-dirs \ |
91 |
| - -Wswitch-default \ |
92 |
| - -Wswitch-enum \ |
93 |
| - -Wunused \ |
94 |
| - -Wunknown-pragmas \ |
95 |
| - -Wstrict-aliasing \ |
96 |
| - -Wstrict-overflow \ |
97 |
| - -Wsystem-headers \ |
98 |
| - -Wfloat-equal \ |
99 |
| - -Wtraditional \ |
100 |
| - -Wtraditional-conversion \ |
101 |
| - -Wdeclaration-after-statement \ |
102 |
| - -Wundef \ |
103 |
| - -Wshadow \ |
104 |
| - -Wunsafe-loop-optimizations \ |
105 |
| - -Wpointer-arith \ |
| 107 | + -Wabi \ |
| 108 | + -Waddress \ |
| 109 | + -Waggressive-loop-optimizations \ |
| 110 | + -Wall \ |
| 111 | + -Warray-bounds \ |
| 112 | + -Wattributes \ |
106 | 113 | -Wbad-function-cast \
|
107 |
| - -Wc++-compat \ |
108 |
| - -Wcast-qual \ |
109 |
| - -Wcast-align \ |
110 |
| - -Wwrite-strings \ |
111 |
| - -Wconversion \ |
112 |
| - -Wsign-conversion \ |
113 |
| - -Wlogical-op \ |
114 |
| - -Waggregate-return \ |
115 |
| - -Wstrict-prototypes \ |
116 |
| - -Wold-style-definition \ |
117 |
| - -Wmissing-prototypes \ |
118 |
| - -Wmissing-declarations \ |
119 |
| - -Wmissing-noreturn \ |
120 |
| - -Wmissing-format-attribute \ |
121 |
| - -Wpacked \ |
122 |
| - -Wpadded \ |
123 |
| - -Wredundant-decls \ |
124 |
| - -Wnested-externs \ |
125 |
| - -Wunreachable-code \ |
126 |
| - -Winline \ |
127 |
| - -Winvalid-pch \ |
128 |
| - -Wlong-long \ |
129 |
| - -Wvla \ |
130 |
| - -Wvolatile-register-var \ |
131 |
| - -Wdisabled-optimization \ |
132 |
| - -Wstack-protector \ |
133 |
| - -Woverlength-strings \ |
134 | 114 | -Wbuiltin-macro-redefined \
|
135 |
| - -Wmudflap \ |
136 |
| - -Wpacked-bitfield-compat \ |
137 |
| - -Wsync-nand \ |
138 |
| - ; do |
139 |
| - gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item" |
140 |
| - done |
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 \ |
144 |
| - -Wattributes \ |
| 115 | + -Wcast-align \ |
| 116 | + -Wchar-subscripts \ |
| 117 | + -Wclobbered \ |
| 118 | + -Wcomment \ |
| 119 | + -Wcomments \ |
145 | 120 | -Wcoverage-mismatch \
|
146 |
| - -Wmultichar \ |
147 |
| - -Wunused-macros \ |
148 |
| - ; do |
149 |
| - gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item" |
150 |
| - done |
151 |
| - # More warnings from gcc 4.6.2 --help=warnings. |
152 |
| - for gl_manywarn_item in \ |
153 |
| - -Wabi \ |
154 | 121 | -Wcpp \
|
| 122 | + -Wdate-time \ |
155 | 123 | -Wdeprecated \
|
156 | 124 | -Wdeprecated-declarations \
|
| 125 | + -Wdisabled-optimization \ |
157 | 126 | -Wdiv-by-zero \
|
158 | 127 | -Wdouble-promotion \
|
| 128 | + -Wempty-body \ |
159 | 129 | -Wendif-labels \
|
| 130 | + -Wenum-compare \ |
160 | 131 | -Wextra \
|
161 | 132 | -Wformat-contains-nul \
|
162 | 133 | -Wformat-extra-args \
|
| 134 | + -Wformat-nonliteral \ |
| 135 | + -Wformat-security \ |
| 136 | + -Wformat-y2k \ |
163 | 137 | -Wformat-zero-length \
|
164 |
| - -Wformat=2 \ |
| 138 | + -Wfree-nonheap-object \ |
| 139 | + -Wignored-qualifiers \ |
| 140 | + -Wimplicit \ |
| 141 | + -Wimplicit-function-declaration \ |
| 142 | + -Wimplicit-int \ |
| 143 | + -Winit-self \ |
| 144 | + -Winline \ |
| 145 | + -Wint-to-pointer-cast \ |
| 146 | + -Winvalid-memory-model \ |
| 147 | + -Winvalid-pch \ |
| 148 | + -Wjump-misses-init \ |
| 149 | + -Wlogical-op \ |
| 150 | + -Wmain \ |
| 151 | + -Wmaybe-uninitialized \ |
| 152 | + -Wmissing-braces \ |
| 153 | + -Wmissing-declarations \ |
| 154 | + -Wmissing-field-initializers \ |
| 155 | + -Wmissing-include-dirs \ |
| 156 | + -Wmissing-parameter-type \ |
| 157 | + -Wmissing-prototypes \ |
165 | 158 | -Wmultichar \
|
166 |
| - -Wnormalized=nfc \ |
| 159 | + -Wnarrowing \ |
| 160 | + -Wnested-externs \ |
| 161 | + -Wnonnull \ |
| 162 | + -Wold-style-declaration \ |
| 163 | + -Wold-style-definition \ |
| 164 | + -Wopenmp-simd \ |
167 | 165 | -Woverflow \
|
| 166 | + -Woverlength-strings \ |
| 167 | + -Woverride-init \ |
| 168 | + -Wpacked \ |
| 169 | + -Wpacked-bitfield-compat \ |
| 170 | + -Wparentheses \ |
| 171 | + -Wpointer-arith \ |
| 172 | + -Wpointer-sign \ |
168 | 173 | -Wpointer-to-int-cast \
|
169 | 174 | -Wpragmas \
|
| 175 | + -Wreturn-local-addr \ |
| 176 | + -Wreturn-type \ |
| 177 | + -Wsequence-point \ |
| 178 | + -Wshadow \ |
| 179 | + -Wsizeof-pointer-memaccess \ |
| 180 | + -Wstack-protector \ |
| 181 | + -Wstrict-aliasing \ |
| 182 | + -Wstrict-overflow \ |
| 183 | + -Wstrict-prototypes \ |
170 | 184 | -Wsuggest-attribute=const \
|
| 185 | + -Wsuggest-attribute=format \ |
171 | 186 | -Wsuggest-attribute=noreturn \
|
172 | 187 | -Wsuggest-attribute=pure \
|
| 188 | + -Wswitch \ |
| 189 | + -Wswitch-default \ |
| 190 | + -Wsync-nand \ |
| 191 | + -Wsystem-headers \ |
173 | 192 | -Wtrampolines \
|
| 193 | + -Wtrigraphs \ |
| 194 | + -Wtype-limits \ |
| 195 | + -Wuninitialized \ |
| 196 | + -Wunknown-pragmas \ |
| 197 | + -Wunsafe-loop-optimizations \ |
| 198 | + -Wunused \ |
| 199 | + -Wunused-but-set-parameter \ |
| 200 | + -Wunused-but-set-variable \ |
| 201 | + -Wunused-function \ |
| 202 | + -Wunused-label \ |
| 203 | + -Wunused-local-typedefs \ |
| 204 | + -Wunused-macros \ |
| 205 | + -Wunused-parameter \ |
| 206 | + -Wunused-result \ |
| 207 | + -Wunused-value \ |
| 208 | + -Wunused-variable \ |
| 209 | + -Wvarargs \ |
| 210 | + -Wvariadic-macros \ |
| 211 | + -Wvector-operation-performance \ |
| 212 | + -Wvla \ |
| 213 | + -Wvolatile-register-var \ |
| 214 | + -Wwrite-strings \ |
| 215 | + \ |
174 | 216 | ; do
|
175 | 217 | gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
|
176 | 218 | done
|
177 | 219 |
|
178 |
| - # Disable the missing-field-initializers warning if needed |
| 220 | + # gcc --help=warnings outputs an unusual form for this option; list |
| 221 | + # it here so that the above 'comm' command doesn't report a false match. |
| 222 | + gl_manywarn_set="$gl_manywarn_set -Wnormalized=nfc" |
| 223 | +
|
| 224 | + # These are needed for older GCC versions. |
| 225 | + if test -n "$GCC"; then |
| 226 | + case `($CC --version) 2>/dev/null` in |
| 227 | + 'gcc (GCC) '[[0-3]].* | \ |
| 228 | + 'gcc (GCC) '4.[[0-7]].*) |
| 229 | + gl_manywarn_set="$gl_manywarn_set -fdiagnostics-show-option" |
| 230 | + gl_manywarn_set="$gl_manywarn_set -funit-at-a-time" |
| 231 | + ;; |
| 232 | + esac |
| 233 | + fi |
| 234 | +
|
| 235 | + # Disable specific options as needed. |
179 | 236 | if test "$gl_cv_cc_nomfi_needed" = yes; then
|
180 | 237 | gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers"
|
181 | 238 | fi
|
182 | 239 |
|
| 240 | + if test "$gl_cv_cc_uninitialized_supported" = no; then |
| 241 | + gl_manywarn_set="$gl_manywarn_set -Wno-uninitialized" |
| 242 | + fi |
| 243 | +
|
183 | 244 | $1=$gl_manywarn_set
|
184 | 245 | ])
|
0 commit comments