]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/warning.m4
[binutils, ARM, 4/16] BF insns infrastructure with array of relocs in struct arm_it
[thirdparty/binutils-gdb.git] / gdb / warning.m4
CommitLineData
b835bb52 1dnl Autoconf configure script for GDB, the GNU debugger.
42a4f53d 2dnl Copyright (C) 1995-2019 Free Software Foundation, Inc.
b835bb52
MF
3dnl
4dnl This file is part of GDB.
5dnl
6dnl This program is free software; you can redistribute it and/or modify
7dnl it under the terms of the GNU General Public License as published by
8dnl the Free Software Foundation; either version 3 of the License, or
9dnl (at your option) any later version.
10dnl
11dnl This program is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14dnl GNU General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
17dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19AC_DEFUN([AM_GDB_WARNINGS],[
20AC_ARG_ENABLE(werror,
21 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
22 [case "${enableval}" in
23 yes | y) ERROR_ON_WARNING="yes" ;;
24 no | n) ERROR_ON_WARNING="no" ;;
25 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
26 esac])
27
28# Enable -Werror by default when using gcc. Turn it off for releases.
29if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" && $development; then
30 ERROR_ON_WARNING=yes
31fi
32
33WERROR_CFLAGS=""
34if test "${ERROR_ON_WARNING}" = yes ; then
35 WERROR_CFLAGS="-Werror"
36fi
37
cf6de44d 38# The options we'll try to enable.
b835bb52 39build_warnings="-Wall -Wpointer-arith \
a0de763e 40-Wno-unused -Wunused-value -Wunused-variable -Wunused-function \
b835bb52 41-Wno-switch -Wno-char-subscripts \
cf6de44d 42-Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable \
d3d8724a 43-Wno-sign-compare -Wno-error=maybe-uninitialized \
7f8a5d38 44-Wno-mismatched-tags \
632e107b 45-Wno-error=deprecated-register \
85e26832 46-Wsuggest-override \
1a34f210 47-Wimplicit-fallthrough=3 \
96643e35
TT
48-Wduplicated-cond \
49-Wshadow=local"
b835bb52 50
b835bb52 51case "${host}" in
4fa7574e
RO
52 *-*-mingw32*)
53 # Enable -Wno-format by default when using gcc on mingw since many
54 # GCC versions complain about %I64.
55 build_warnings="$build_warnings -Wno-format" ;;
56 *-*-solaris*)
57 # Solaris 11.4 <python2.7/ceval.h> uses #pragma no_inline that GCC
58 # doesn't understand.
59 build_warnings="$build_warnings -Wno-unknown-pragmas"
60 # Solaris 11 <unistd.h> marks vfork deprecated.
61 build_warnings="$build_warnings -Wno-deprecated-declarations" ;;
f1628857
TT
62 *)
63 # Note that gcc requires -Wformat for -Wformat-nonliteral to work,
64 # but there's a special case for this below.
65 build_warnings="$build_warnings -Wformat-nonliteral" ;;
b835bb52
MF
66esac
67
68AC_ARG_ENABLE(build-warnings,
69AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]),
70[case "${enableval}" in
71 yes) ;;
72 no) build_warnings="-w";;
73 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
74 build_warnings="${build_warnings} ${t}";;
75 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
76 build_warnings="${t} ${build_warnings}";;
77 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
78esac
79if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
80 echo "Setting compiler warning flags = $build_warnings" 6>&1
81fi])dnl
82AC_ARG_ENABLE(gdb-build-warnings,
83AS_HELP_STRING([--enable-gdb-build-warnings], [enable GDB specific build-time compiler warnings if gcc is used]),
84[case "${enableval}" in
85 yes) ;;
86 no) build_warnings="-w";;
87 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
88 build_warnings="${build_warnings} ${t}";;
89 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
90 build_warnings="${t} ${build_warnings}";;
91 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
92esac
93if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
94 echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
95fi])dnl
96
97# The set of warnings supported by a C++ compiler is not the same as
98# of the C compiler.
cf6de44d 99AC_LANG_PUSH([C++])
b835bb52
MF
100
101WARN_CFLAGS=""
102if test "x${build_warnings}" != x -a "x$GCC" = xyes
103then
104 AC_MSG_CHECKING(compiler warning flags)
105 # Separate out the -Werror flag as some files just cannot be
106 # compiled with it enabled.
107 for w in ${build_warnings}; do
108 # GCC does not complain about -Wno-unknown-warning. Invert
109 # and test -Wunknown-warning instead.
110 case $w in
111 -Wno-*)
112 wtest=`echo $w | sed 's/-Wno-/-W/g'` ;;
f1628857
TT
113 -Wformat-nonliteral)
114 # gcc requires -Wformat before -Wformat-nonliteral
115 # will work, so stick them together.
116 w="-Wformat $w"
117 wtest="$w"
118 ;;
b835bb52
MF
119 *)
120 wtest=$w ;;
121 esac
122
123 case $w in
124 -Werr*) WERROR_CFLAGS=-Werror ;;
125 *)
126 # Check whether GCC accepts it.
127 saved_CFLAGS="$CFLAGS"
3e019bdc 128 CFLAGS="$CFLAGS -Werror $wtest"
b835bb52 129 saved_CXXFLAGS="$CXXFLAGS"
3e019bdc 130 CXXFLAGS="$CXXFLAGS -Werror $wtest"
a0de763e
TT
131 if test "x$w" = "x-Wunused-variable"; then
132 # Check for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38958,
133 # fixed in GCC 4.9. This test is derived from the gdb
134 # source code that triggered this bug in GCC.
135 AC_TRY_COMPILE(
136 [struct scoped_restore_base {};
137 struct scoped_restore_tmpl : public scoped_restore_base {
138 ~scoped_restore_tmpl() {}
139 };],
140 [const scoped_restore_base &b = scoped_restore_tmpl();],
141 WARN_CFLAGS="${WARN_CFLAGS} $w",)
142 else
143 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
144 fi
b835bb52
MF
145 CFLAGS="$saved_CFLAGS"
146 CXXFLAGS="$saved_CXXFLAGS"
147 esac
148 done
149 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
150fi
151AC_SUBST(WARN_CFLAGS)
152AC_SUBST(WERROR_CFLAGS)
153
cf6de44d 154AC_LANG_POP([C++])
b835bb52 155])