1
# manywarnings.m4 serial 1
2
dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
1
# manywarnings.m4 serial 5
2
dnl Copyright (C) 2008-2012 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.
31
31
# gl_MANYWARN_ALL_GCC(VARIABLE)
32
32
# -----------------------------
33
# Add all documented GCC (currently as per version 4.4) warning
34
# parameters to variable VARIABLE. Note that you need to test them
35
# using gl_WARN_ADD if you want to make sure your gcc understands it.
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
36
AC_DEFUN([gl_MANYWARN_ALL_GCC],
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
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], [
78
76
AC_MSG_RESULT([$gl_cv_cc_nomfi_needed])
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"
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])
95
# List all gcc warning categories.
83
97
for gl_manywarn_item in \
104
-Wbad-function-cast \
105
-Wbuiltin-macro-redefined \
111
-Wcoverage-mismatch \
114
-Wdeprecated-declarations \
115
-Wdisabled-optimization \
122
-Wformat-contains-nul \
123
-Wformat-extra-args \
87
124
-Wformat-nonliteral \
88
125
-Wformat-security \
127
-Wformat-zero-length \
129
-Wfree-nonheap-object \
130
-Wignored-qualifiers \
132
-Wimplicit-function-declaration \
90
-Wmissing-include-dirs \
100
-Wtraditional-conversion \
101
-Wdeclaration-after-statement \
104
-Wunsafe-loop-optimizations \
106
-Wbad-function-cast \
136
-Wint-to-pointer-cast \
137
-Winvalid-memory-model \
115
-Wstrict-prototypes \
116
-Wold-style-definition \
117
-Wmissing-prototypes \
142
-Wmaybe-uninitialized \
118
144
-Wmissing-declarations \
145
-Wmissing-field-initializers \
146
-Wmissing-format-attribute \
147
-Wmissing-include-dirs \
119
148
-Wmissing-noreturn \
120
-Wmissing-format-attribute \
149
-Wmissing-parameter-type \
150
-Wmissing-prototypes \
124
154
-Wnested-externs \
130
-Wvolatile-register-var \
131
-Wdisabled-optimization \
157
-Wold-style-declaration \
158
-Wold-style-definition \
133
160
-Woverlength-strings \
134
-Wbuiltin-macro-redefined \
136
163
-Wpacked-bitfield-compat \
167
-Wpointer-to-int-cast \
172
-Wsizeof-pointer-memaccess \
176
-Wstrict-prototypes \
177
-Wsuggest-attribute=const \
178
-Wsuggest-attribute=format \
179
-Wsuggest-attribute=noreturn \
180
-Wsuggest-attribute=pure \
139
gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
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 \
145
-Wcoverage-mismatch \
191
-Wunsafe-loop-optimizations \
193
-Wunused-but-set-parameter \
194
-Wunused-but-set-variable \
197
-Wunused-local-typedefs \
147
198
-Wunused-macros \
205
-Wvector-operation-performance \
207
-Wvolatile-register-var \
149
211
gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
152
# Disable the missing-field-initializers warning if needed
214
# Disable specific options as needed.
153
215
if test "$gl_cv_cc_nomfi_needed" = yes; then
154
216
gl_manywarn_set="$gl_manywarn_set -Wno-missing-field-initializers"
219
if test "$gl_cv_cc_uninitialized_supported" = no; then
220
gl_manywarn_set="$gl_manywarn_set -Wno-uninitialized"
157
223
$1=$gl_manywarn_set