Use visitors for make_gdb_type
[deliverable/binutils-gdb.git] / gdb / warning.m4
... / ...
CommitLineData
1dnl Autoconf configure script for GDB, the GNU debugger.
2dnl Copyright (C) 1995-2018 Free Software Foundation, Inc.
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
38# The options we'll try to enable.
39build_warnings="-Wall -Wpointer-arith \
40-Wno-unused -Wunused-value -Wunused-function \
41-Wno-switch -Wno-char-subscripts \
42-Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable \
43-Wno-sign-compare -Wno-narrowing -Wno-error=maybe-uninitialized \
44-Wno-mismatched-tags"
45
46case "${host}" in
47 *-*-mingw32*)
48 # Enable -Wno-format by default when using gcc on mingw since many
49 # GCC versions complain about %I64.
50 build_warnings="$build_warnings -Wno-format" ;;
51 *-*-solaris*)
52 # Solaris 11.4 <python2.7/ceval.h> uses #pragma no_inline that GCC
53 # doesn't understand.
54 build_warnings="$build_warnings -Wno-unknown-pragmas"
55 # Solaris 11 <unistd.h> marks vfork deprecated.
56 build_warnings="$build_warnings -Wno-deprecated-declarations" ;;
57 *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
58esac
59
60AC_ARG_ENABLE(build-warnings,
61AS_HELP_STRING([--enable-build-warnings], [enable build-time compiler warnings if gcc is used]),
62[case "${enableval}" in
63 yes) ;;
64 no) build_warnings="-w";;
65 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
66 build_warnings="${build_warnings} ${t}";;
67 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
68 build_warnings="${t} ${build_warnings}";;
69 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
70esac
71if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
72 echo "Setting compiler warning flags = $build_warnings" 6>&1
73fi])dnl
74AC_ARG_ENABLE(gdb-build-warnings,
75AS_HELP_STRING([--enable-gdb-build-warnings], [enable GDB specific build-time compiler warnings if gcc is used]),
76[case "${enableval}" in
77 yes) ;;
78 no) build_warnings="-w";;
79 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
80 build_warnings="${build_warnings} ${t}";;
81 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
82 build_warnings="${t} ${build_warnings}";;
83 *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
84esac
85if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
86 echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
87fi])dnl
88
89# The set of warnings supported by a C++ compiler is not the same as
90# of the C compiler.
91AC_LANG_PUSH([C++])
92
93WARN_CFLAGS=""
94if test "x${build_warnings}" != x -a "x$GCC" = xyes
95then
96 AC_MSG_CHECKING(compiler warning flags)
97 # Separate out the -Werror flag as some files just cannot be
98 # compiled with it enabled.
99 for w in ${build_warnings}; do
100 # GCC does not complain about -Wno-unknown-warning. Invert
101 # and test -Wunknown-warning instead.
102 case $w in
103 -Wno-*)
104 wtest=`echo $w | sed 's/-Wno-/-W/g'` ;;
105 *)
106 wtest=$w ;;
107 esac
108
109 case $w in
110 -Werr*) WERROR_CFLAGS=-Werror ;;
111 *)
112 # Check whether GCC accepts it.
113 saved_CFLAGS="$CFLAGS"
114 CFLAGS="$CFLAGS -Werror $wtest"
115 saved_CXXFLAGS="$CXXFLAGS"
116 CXXFLAGS="$CXXFLAGS -Werror $wtest"
117 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
118 CFLAGS="$saved_CFLAGS"
119 CXXFLAGS="$saved_CXXFLAGS"
120 esac
121 done
122 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
123fi
124AC_SUBST(WARN_CFLAGS)
125AC_SUBST(WERROR_CFLAGS)
126
127AC_LANG_POP([C++])
128])
This page took 0.028124 seconds and 4 git commands to generate.