Prevent a seg-fault in gprof when parsing a corrupt core file.
[deliverable/binutils-gdb.git] / bfd / warning.m4
CommitLineData
1110793a 1dnl Common configure.ac fragment
5bf135a7 2dnl
6f2750fe 3dnl Copyright (C) 2012-2016 Free Software Foundation, Inc.
5bf135a7
NC
4dnl
5dnl This file is free software; you can redistribute it and/or modify
6dnl it under the terms of the GNU General Public License as published by
7dnl the Free Software Foundation; either version 3 of the License, or
8dnl (at your option) any later version.
1b786873 9dnl
5bf135a7
NC
10dnl This program is distributed in the hope that it will be useful,
11dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13dnl GNU General Public License for more details.
1b786873 14dnl
5bf135a7
NC
15dnl You should have received a copy of the GNU General Public License
16dnl along with this program; see the file COPYING3. If not see
17dnl <http://www.gnu.org/licenses/>.
18dnl
9e9b66a9
AM
19
20AC_DEFUN([AM_BINUTILS_WARNINGS],[
270c9937
JB
21# Set the 'development' global.
22. $srcdir/../bfd/development.sh
23
9780e045 24# Default set of GCC warnings to enable.
d1a98e0c 25GCC_WARN_CFLAGS="-W -Wall -Wstrict-prototypes -Wmissing-prototypes"
9780e045
NC
26
27# Add -Wshadow if the compiler is a sufficiently recent version of GCC.
d1a98e0c 28AC_EGREP_CPP([^[0-3]$],[__GNUC__],,GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wshadow")
9e9b66a9 29
9780e045
NC
30# Add -Wstack-usage if the compiler is a sufficiently recent version of GCC.
31AC_EGREP_CPP([^[0-4]$],[__GNUC__],,GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wstack-usage=262144")
32
6757cf57
TS
33# Set WARN_WRITE_STRINGS if the compiler supports -Wwrite-strings.
34WARN_WRITE_STRINGS=""
35AC_EGREP_CPP([^[0-3]$],[__GNUC__],,WARN_WRITE_STRINGS="-Wwrite-strings")
9780e045 36
9e9b66a9 37AC_ARG_ENABLE(werror,
241a6c40 38 [ --enable-werror treat compile warnings as errors],
9e9b66a9
AM
39 [case "${enableval}" in
40 yes | y) ERROR_ON_WARNING="yes" ;;
41 no | n) ERROR_ON_WARNING="no" ;;
42 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
43 esac])
44
d1a98e0c 45# Disable -Wformat by default when using gcc on mingw
bb8541b9
L
46case "${host}" in
47 *-*-mingw32*)
48 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
49 GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Wno-format"
50 fi
51 ;;
52 *) ;;
53esac
54
270c9937
JB
55# Enable -Werror by default when using gcc. Turn it off for releases.
56if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" -a "$development" = true ; then
9e9b66a9
AM
57 ERROR_ON_WARNING=yes
58fi
59
60NO_WERROR=
61if test "${ERROR_ON_WARNING}" = yes ; then
9780e045 62 GCC_WARN_CFLAGS="$GCC_WARN_CFLAGS -Werror"
9e9b66a9
AM
63 NO_WERROR="-Wno-error"
64fi
1b786873 65
49c96104
SE
66if test "${GCC}" = yes ; then
67 WARN_CFLAGS="${GCC_WARN_CFLAGS}"
68fi
69
9e9b66a9 70AC_ARG_ENABLE(build-warnings,
241a6c40 71[ --enable-build-warnings enable build-time compiler warnings],
9e9b66a9 72[case "${enableval}" in
49c96104
SE
73 yes) WARN_CFLAGS="${GCC_WARN_CFLAGS}";;
74 no) if test "${GCC}" = yes ; then
75 WARN_CFLAGS="-w"
76 fi;;
9e9b66a9 77 ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
49c96104 78 WARN_CFLAGS="${GCC_WARN_CFLAGS} ${t}";;
9e9b66a9 79 *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
49c96104 80 WARN_CFLAGS="${t} ${GCC_WARN_CFLAGS}";;
9e9b66a9
AM
81 *) WARN_CFLAGS=`echo "${enableval}" | sed -e "s/,/ /g"`;;
82esac])
83
84if test x"$silent" != x"yes" && test x"$WARN_CFLAGS" != x""; then
85 echo "Setting warning flags = $WARN_CFLAGS" 6>&1
86fi
87
88AC_SUBST(WARN_CFLAGS)
89AC_SUBST(NO_WERROR)
6757cf57 90 AC_SUBST(WARN_WRITE_STRINGS)
9e9b66a9 91])
This page took 0.605315 seconds and 4 git commands to generate.