* syms.c (_bfd_stab_section_find_nearest_line): Add last_str
[deliverable/binutils-gdb.git] / config / warnings.m4
CommitLineData
9a8371d2
DD
1# Autoconf include file defining macros related to compile-time warnings.
2
a53e62cf 3# Copyright 2004, 2005, 2007, 2009, 2011 Free Software Foundation, Inc.
9a8371d2
DD
4
5#This file is part of GCC.
6
7#GCC is free software; you can redistribute it and/or modify it under
8#the terms of the GNU General Public License as published by the Free
ca892441 9#Software Foundation; either version 3, or (at your option) any later
9a8371d2
DD
10#version.
11
12#GCC is distributed in the hope that it will be useful, but WITHOUT
13#ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14#FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15#for more details.
16
17#You should have received a copy of the GNU General Public License
ca892441
RW
18#along with GCC; see the file COPYING3. If not see
19#<http://www.gnu.org/licenses/>.
9a8371d2 20
ceb92e78 21# ACX_PROG_CC_WARNING_OPTS(WARNINGS, [VARIABLE = WARN_CFLAGS)
aa075251 22# Sets @VARIABLE@ to the subset of the given options which the
9a8371d2
DD
23# compiler accepts.
24AC_DEFUN([ACX_PROG_CC_WARNING_OPTS],
25[AC_REQUIRE([AC_PROG_CC])dnl
aa075251
PB
26m4_pushdef([acx_Var], [m4_default([$2], [WARN_CFLAGS])])dnl
27AC_SUBST(acx_Var)dnl
ceb92e78
PB
28m4_expand_once([acx_Var=
29],m4_quote(acx_Var=))dnl
9a8371d2 30save_CFLAGS="$CFLAGS"
a53e62cf
AS
31for real_option in $1; do
32 # Do the check with the no- prefix removed since gcc silently
33 # accepts any -Wno-* option on purpose
34 case $real_option in
604fcd65 35 -Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;;
a53e62cf
AS
36 *) option=$real_option ;;
37 esac
9a8371d2
DD
38 AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option])
39 AC_CACHE_CHECK([whether $CC supports $option], acx_Woption,
40 [CFLAGS="$option"
41 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
42 [AS_VAR_SET(acx_Woption, yes)],
43 [AS_VAR_SET(acx_Woption, no)])
44 ])
45 AS_IF([test AS_VAR_GET(acx_Woption) = yes],
a53e62cf 46 [acx_Var="$acx_Var${acx_Var:+ }$real_option"])
9a8371d2
DD
47 AS_VAR_POPDEF([acx_Woption])dnl
48done
49CFLAGS="$save_CFLAGS"
aa075251 50m4_popdef([acx_Var])dnl
9a8371d2
DD
51])# ACX_PROG_CC_WARNING_OPTS
52
a53e62cf 53# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC])
aa075251 54# Append to VARIABLE "-pedantic" + the argument, if the compiler is GCC
5452212a 55# and accepts all of those options simultaneously, otherwise to nothing.
9a8371d2
DD
56AC_DEFUN([ACX_PROG_CC_WARNING_ALMOST_PEDANTIC],
57[AC_REQUIRE([AC_PROG_CC])dnl
aa075251
PB
58m4_pushdef([acx_Var], [m4_default([$2], [WARN_PEDANTIC])])dnl
59AC_SUBST(acx_Var)dnl
ceb92e78
PB
60m4_expand_once([acx_Var=
61],m4_quote(acx_Var=))dnl
a53e62cf
AS
62# Do the check with the no- prefix removed from the warning options
63# since gcc silently accepts any -Wno-* option on purpose
64m4_pushdef([acx_Woptions], [m4_bpatsubst([$1], [-Wno-], [-W])])dnl
65AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_]acx_Woptions)dnl
f1166a09 66AS_IF([test "$GCC" = yes],
a53e62cf 67[AC_CACHE_CHECK([whether $CC supports -pedantic ]acx_Woptions, acx_Pedantic,
9a8371d2 68[save_CFLAGS="$CFLAGS"
a53e62cf 69CFLAGS="-pedantic acx_Woptions"
9a8371d2
DD
70AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
71 [AS_VAR_SET(acx_Pedantic, yes)],
72 [AS_VAR_SET(acx_Pedantic, no)])
73CFLAGS="$save_CFLAGS"])
74AS_IF([test AS_VAR_GET(acx_Pedantic) = yes],
aa075251 75 [acx_Var="$acx_Var${acx_Var:+ }-pedantic $1"])
5452212a 76])
9a8371d2 77AS_VAR_POPDEF([acx_Pedantic])dnl
a53e62cf 78m4_popdef([acx_Woptions])dnl
aa075251 79m4_popdef([acx_Var])dnl
9a8371d2
DD
80])# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC
81
ceb92e78
PB
82# ACX_PROG_CC_WARNINGS_ARE_ERRORS([x.y.z], [VARIABLE = WERROR])
83# sets @VARIABLE@ to "-Werror" if the compiler is GCC >=x.y.z, or if
9a8371d2
DD
84# --enable-werror-always was given on the command line, otherwise
85# to nothing.
86# If the argument is the word "manual" instead of a version number,
ceb92e78 87# then @VARIABLE@ will be set to -Werror only if --enable-werror-always
9a8371d2
DD
88# appeared on the configure command line.
89AC_DEFUN([ACX_PROG_CC_WARNINGS_ARE_ERRORS],
90[AC_REQUIRE([AC_PROG_CC])dnl
ceb92e78
PB
91m4_pushdef([acx_Var], [m4_default([$2], [WERROR])])dnl
92AC_SUBST(acx_Var)dnl
93m4_expand_once([acx_Var=
94],m4_quote(acx_Var=))dnl
9a8371d2
DD
95AC_ARG_ENABLE(werror-always,
96 AS_HELP_STRING([--enable-werror-always],
97 [enable -Werror despite compiler version]),
98[], [enable_werror_always=no])
99AS_IF([test $enable_werror_always = yes],
ceb92e78 100 [acx_Var="$acx_Var${acx_Var:+ }-Werror"])
9a8371d2
DD
101 m4_if($1, [manual],,
102 [AS_VAR_PUSHDEF([acx_GCCvers], [acx_cv_prog_cc_gcc_$1_or_newer])dnl
103 AC_CACHE_CHECK([whether $CC is GCC >=$1], acx_GCCvers,
104 [set fnord `echo $1 | tr '.' ' '`
105 shift
106 AC_PREPROC_IFELSE(
107[#if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ \
108 < [$]1 * 10000 + [$]2 * 100 + [$]3
109#error insufficient
110#endif],
111 [AS_VAR_SET(acx_GCCvers, yes)],
112 [AS_VAR_SET(acx_GCCvers, no)])])
113 AS_IF([test AS_VAR_GET(acx_GCCvers) = yes],
ceb92e78
PB
114 [acx_Var="$acx_Var${acx_Var:+ }-Werror"])
115 AS_VAR_POPDEF([acx_GCCvers])])
116m4_popdef([acx_Var])dnl
9a8371d2 117])# ACX_PROG_CC_WARNINGS_ARE_ERRORS
This page took 0.311154 seconds and 4 git commands to generate.