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