[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Turn on compiler warnings by default for AC_PROG_CC, AC_PROG_CXX & A
From: |
Visser, Dale |
Subject: |
Re: Turn on compiler warnings by default for AC_PROG_CC, AC_PROG_CXX & AC_PROG_FC |
Date: |
Tue, 2 Dec 2014 11:45:43 -0500 |
I have an updated patch (see below) inspired by "goto fail", in particular, a
recent essay by David Wheeler (see
http://www.dwheeler.com/essays/apple-goto-fail.html). The clang compiler would
have caught the "goto fail" issue if it had been used to analyze the code with
the -Wunreachable-code option enabled. This patch is only slightly modified
from my previous version in that it will add -Wunreachable-code in addition to
-Wall for both clang and gcc.
Unfortunately, on gcc, this is now a no-op. But even those who build with gcc
may use clang for analysis. At some future point, gcc may stop silently
ignoring -Wunreachable-code (see
https://gcc.gnu.org/ml/gcc-help/2011-05/msg00360.html), and I have covered for
that, too. When and if that happens, only -Wall will be used for gcc.
Best regards,
Dale
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index ace1675..68db110 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -7214,6 +7214,15 @@ other compilers. If your package does not like this
default, then it is
acceptable to insert the line @samp{: address@hidden""@}} after @code{AC_INIT}
and before @code{AC_PROG_CC} to select an empty default instead.
+Scan for common flags that enable compiler warnings. If found, append them
+to @code{CFLAGS}. To modify this behaviour, for example, to restore the old
+no-warning-flag behaviour, add the following line before you invoke
address@hidden:
+
address@hidden
address@hidden:address@hidden
address@hidden example
+
Many Autoconf macros use a compiler, and thus call
@samp{AC_REQUIRE([AC_PROG_CC])} to ensure that the compiler has been
determined before the body of the outermost @code{AC_DEFUN} macro.
@@ -7604,6 +7613,16 @@ systems where G++ does not accept @option{-g}), or
@option{-g} for other
compilers. If your package does not like this default, then it is
acceptable to insert the line @samp{: address@hidden""@}} after @code{AC_INIT}
and before @code{AC_PROG_CXX} to select an empty default instead.
+
+Scan for common flags that enable compiler warnings. If found, append them
+to @code{CXXFLAGS}. To modify this behaviour, for example, to restore the old
+no-warning-flag behaviour, add the following line before you invoke
address@hidden:
+
address@hidden
address@hidden:address@hidden
address@hidden example
+
@end defmac
@defmac AC_PROG_CXXCPP
@@ -7868,6 +7887,17 @@ environment, then set it to @option{-g -02} for a GNU
Fortran compiler (or
The result of the GNU test is cached in the @code{ac_cv_fc_compiler_gnu}
variable, acceptance of @option{-g} in the @code{ac_cv_prog_fc_g}
variable.
+
+Scan for common flags that enable compiler warnings. If found, append them
+to @code{FCFLAGS}. To modify this behaviour, for example, to restore the old
+no-warning-flag behaviour, add the following line before you invoke
address@hidden:
+
address@hidden
address@hidden:address@hidden
address@hidden example
+
+
@end defmac
@defmac AC_PROG_F77_C_O
@@ -23472,6 +23502,158 @@ The current language does not change.
@code{AC_LANG_PUSH} is preferred
(@pxref{AC_LANG_PUSH}).
@end defmac
address@hidden
address@hidden AC_CFLAGS_WARN_ALL (@var{shell-variable-to-add-to},
@var{add-value-if-not-found}, @var{action-if-found}, @var{action-if-not-found})
address@hidden
+Try to find a C compiler option that enables most reasonable warnings. See
address@hidden for how to use the (optional) parameters. The most
+typical usage is shown below.
+
address@hidden
+AC_CFLAGS_WARN_ALL
address@hidden example
address@hidden defmac
+
address@hidden
address@hidden AC_CXXFLAGS_WARN_ALL (@var{shell-variable-to-add-to},
@var{add-value-if-not-found}, @var{action-if-found}, @var{action-if-not-found})
address@hidden
+Try to find a C++ compiler option that enables most reasonable warnings. See
address@hidden for how to use the (optional) parameters. The most
+typical usage is shown below.
+
address@hidden
+AC_CXXFLAGS_WARN_ALL
address@hidden example
address@hidden defmac
+
address@hidden
address@hidden AC_FCFLAGS_WARN_ALL (@var{shell-variable-to-add-to},
@var{add-value-if-not-found}, @var{action-if-found}, @var{action-if-not-found})
address@hidden
+Try to find a Fortran compiler option that enables most reasonable warnings.
+See @pxref{AC_FLAGS_WARN_ALL} for how to use the (optional) parameters. The
most
+typical usage is shown below.
+
address@hidden
+AC_FCFLAGS_WARN_ALL
address@hidden example
address@hidden defmac
+
address@hidden
address@hidden AC_FLAGS_WARN_ALL (@var{shell-variable-to-add-to},
@var{add-value-if-not-found}, @var{action-if-found}, @var{action-if-not-found})
address@hidden
+Try to find a compiler option that enables most reasonable warnings.
+
+Usually not used directly. Instead, use @pxref{AC_CFLAGS_WARN_ALL},
address@hidden, or @pxref{AC_FCFLAGS_WARN_ALL}, all of which
+perform a requisite @pxref{AC_LANG_PUSH}, and then invoke this macro without
+altering any positional parameters they were provided. To use with another
+language, such as Objective C, it is necessary to first push the language
+first.
+
address@hidden
+AC_LANG_PUSH([Objective C])
+AC_FLAGS_WARN_ALL
+AC_LANG_POP
address@hidden example
+
+The first positional parameter defines the shell variable to use, and
+if not provided, depends on @pxref{AC_LANG_PUSH} having been invoked properly.
+If appropriate warning flag values can be automatically determined for the
+compiler, then the third positional parameter (if present) defines an
+alternate action to take instead of appending to the shell variable. If no
+appropriate warning flag values could be determined, then the second
+positional parameter (if present) defines alternate flags to append to the
+shell variable, unless the fourth positional parameter is present, in which
+case it defines an alternate action to take instead of appending to the shell
+variable.
+
address@hidden is invoked by @code{AC_PROG_CC}, @code{AC_PROG_CXX},
+and @code{AC_PROG_FC} by default. The addition of the detected default
+warning flags is controlled by the "default_warning_flags" feature, which is
+enabled by default. It may be disabled with an option passed to the generated
+configure script. To suppress the actual addition of any default warning
+flags in the configure.ac file, i.e., to restore the behavior from previous
+versions of autoconf, add the following line before you invoke
address@hidden, whether explicitly or implicitly:
+
address@hidden
address@hidden:address@hidden
address@hidden example
address@hidden defmac
+
address@hidden
address@hidden AC_APPEND_FLAG (@var{add-value})
address@hidden
+Append the given flag to the FLAGS variable previously determined, but only if
+the given flag is not already present. Used internally by
address@hidden Typically, it is desirable to use
address@hidden instead, since that performs additional a check
+on the given flag.
address@hidden defmac
+
address@hidden
address@hidden AC_APPEND_CFLAG_IFVALID (@var{add-value})
address@hidden
+Sets the current language to C, then invokes @pxref{AC_APPEND_FLAG_IFVALID}.
+The following example shows a typical usage, adding @option{-Wfancy-warnings}
+on top of whatever warning flags are already added for the current C
+compiler, but only if @option{-Wfancy-warnings} is a valid flag.
+
address@hidden
+AC_PROG_CC
+AC_APPEND_CFLAG_IFVALID([-Wfancy-warnings])
address@hidden example
+
address@hidden defmac
+
address@hidden
address@hidden AC_APPEND_CXXFLAG_IFVALID (@var{add-value})
address@hidden
+Sets the current language to C++, then invokes @pxref{AC_APPEND_FLAG_IFVALID}.
+The following example shows a typical usage, adding @option{-Wfancy-warnings}
+on top of whatever warning flags are already added for the current C++
+compiler, but only if @option{-Wfancy-warnings} is a valid flag.
+
address@hidden
+AC_PROG_CXX
+AC_APPEND_CXXFLAG_IFVALID([-Wfancy-warnings])
address@hidden example
+
address@hidden defmac
+
address@hidden
address@hidden AC_APPEND_FCFLAG_IFVALID (@var{add-value})
address@hidden
+Sets the current language to Fortran, then invokes
address@hidden
+The following example shows a typical usage, adding @option{-Wfancy-warnings}
+on top of whatever warning flags are already added for the current Fortran
+compiler, but only if @option{-Wfancy-warnings} is a valid flag.
+
address@hidden
+AC_PROG_FC
+AC_APPEND_FCFLAG_IFVALID([-Wfancy-warnings])
address@hidden example
address@hidden defmac
+
address@hidden
address@hidden AC_APPEND_FLAG_IFVALID (@var{add-value})
address@hidden
+Determine the appropriate compiler flags variable for the current language,
+compile a test program using the given flag(s), and if the compile process
+exits normally, append it to the flags variable using @pxref{AC_APPEND_FLAG}.
+Used internally by @pxref{AC_APPEND_CFLAG_IFVALID},
address@hidden, and @pxref{AC_APPEND_FCFLAG_IFVALID}. To
+use with another language, such as Objective C, it is necessary to first push
+the language first.
+
address@hidden
+AC_LANG_PUSH([Objective C])
+AC_APPEND_FLAG_IFVALID([-Wno-comment])
+AC_LANG_POP
address@hidden example
address@hidden defmac
+
@defmac AC_LINK_FILES (@address@hidden, @address@hidden)
@acindex{LINK_FILES}
This is an obsolete version of @code{AC_CONFIG_LINKS}
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 9b7aa6b..2537ed9 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -429,6 +429,9 @@ AU_DEFUN([ac_cv_prog_gcc],
# COMPILER ... is a space separated list of C compilers to search for.
# This just gives the user an opportunity to specify an alternative
# search list for the C compiler.
+# To avoid the automatic addition of some default compiler warning flags,
+# add the following line before you invoke AC_PROG_CC:
+# enable_default_warning_flags=${enable_default_warning_flags:-no}
AN_MAKEVAR([CC], [AC_PROG_CC])
AN_PROGRAM([cc], [AC_PROG_CC])
AN_PROGRAM([gcc], [AC_PROG_CC])
@@ -491,6 +494,7 @@ _AC_PROG_CC_C11([ac_prog_cc_stdc=c11
[ac_prog_cc_stdc=no
ac_cv_prog_cc_stdc=no])])])
dnl
+AC_FLAGS_WARN_ALL
AC_LANG_POP(C)dnl
])# AC_PROG_CC
@@ -686,6 +690,9 @@ AU_DEFUN([ac_cv_prog_gxx],
# RCC Rational C++
# xlC_r AIX C Set++ (with support for reentrant code)
# xlC AIX C Set++
+# To avoid the automatic addition of some default compiler warning flags,
+# add the following line before you invoke AC_PROG_CXX:
+# enable_default_warning_flags=${enable_default_warning_flags:-no}
AN_MAKEVAR([CXX], [AC_PROG_CXX])
AN_PROGRAM([CC], [AC_PROG_CXX])
AN_PROGRAM([c++], [AC_PROG_CXX])
@@ -732,6 +739,7 @@ _AC_PROG_CXX_CXX11([ac_prog_cxx_stdcxx=cxx11
ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98],
[ac_prog_cxx_stdcxx=no
ac_cv_prog_cxx_stdcxx=no])])
+AC_FLAGS_WARN_ALL
AC_LANG_POP(C++)dnl
])# AC_PROG_CXX
diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4
index e0f66f1..ffe7aba 100644
--- a/lib/autoconf/fortran.m4
+++ b/lib/autoconf/fortran.m4
@@ -375,6 +375,9 @@ AC_LANG_POP(Fortran 77)dnl
# -------------------------------------
# COMPILERS is a space separated list of Fortran 77 compilers to search
# for, and [DIALECT] is an optional dialect. See also _AC_PROG_FC.
+# To avoid the automatic addition of some default compiler warning flags,
+# add the following line before you invoke AC_PROG_FC:
+# enable_default_warning_flags=${enable_default_warning_flags:-no}
AC_DEFUN([AC_PROG_FC],
[AC_LANG_PUSH(Fortran)dnl
AC_ARG_VAR([FC], [Fortran compiler command])dnl
@@ -387,6 +390,7 @@ if test $ac_compiler_gnu = yes; then
else
GFC=
fi
+AC_FLAGS_WARN_ALL
AC_LANG_POP(Fortran)dnl
])# AC_PROG_FC
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 59d204f..aff8540 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -433,6 +433,7 @@ m4_wrap_lifo([m4_divert_text([DEFAULTS],
ac_subst_files='m4_ifdef([_AC_SUBST_FILES], [m4_defn([_AC_SUBST_FILES])])'
ac_user_opts='
enable_option_checking
+enable_default_warning_flags
m4_ifdef([_AC_USER_OPTS], [m4_defn([_AC_USER_OPTS])
])'
m4_ifdef([_AC_PRECIOUS_VARS],
@@ -1447,6 +1448,9 @@ AC_DEFUN([AC_PRESERVE_HELP_ORDER],
[m4_divert_once([HELP_ENABLE], [[
Optional Features and Packages:
--disable-option-checking ignore unrecognized --enable/--with options
+ --disable-default-warning-flags
+ suppresses the addition of automatically determined
+ default compiler warning flags
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -1478,6 +1482,9 @@ AC_DEFUN([AC_ARG_ENABLE],
[m4_divert_once([HELP_ENABLE], [[
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
+ --disable-default-warning-flags
+ suppresses the addition of automatically determined
+ default compiler warning flags
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]]])])dnl
m4_divert_once([HELP_ENABLE], [$2])dnl
@@ -2633,9 +2640,11 @@ m4_define([_AC_COMPILE_IFELSE_BODY],
])# _AC_COMPILE_IFELSE_BODY
-# _AC_COMPILE_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+# _AC_COMPILE_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE], [ERRFILE])
# ----------------------------------------------------------------
# Try to compile PROGRAM.
+# If ERRFILE is provided, any contents of the stderr will be placed
+# in ERRFILE, which should be deleted by the caller.
# This macro can be used during the selection of a compiler.
AC_DEFUN([_AC_COMPILE_IFELSE],
[AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_try_compile],
@@ -2644,10 +2653,10 @@ AC_DEFUN([_AC_COMPILE_IFELSE],
[$0_BODY])]dnl
[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])]dnl
[AS_IF([ac_fn_[]_AC_LANG_ABBREV[]_try_compile "$LINENO"], [$2], [$3])
+m4_ifvaln([$4], [cp conftest.err "$4"])
rm -f core conftest.err conftest.$ac_objext[]m4_ifval([$1], [
conftest.$ac_ext])[]dnl
])# _AC_COMPILE_IFELSE
-
# AC_COMPILE_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
# ---------------------------------------------------------------
# Try to compile PROGRAM. Requires that the compiler for the current
@@ -2697,11 +2706,14 @@ m4_define([_AC_LINK_IFELSE_BODY],
])# _AC_LINK_IFELSE_BODY
-# _AC_LINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+# _AC_LINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE], [ERRFILE])
# -------------------------------------------------------------
# Try to link PROGRAM.
# This macro can be used during the selection of a compiler.
#
+# If ERRFILE is provided, any contents of the stderr will be placed
+# in ERRFILE, which should be deleted by the caller.
+#
# Test that resulting file is executable; see the problem reported by mwoehlke
# in <http://lists.gnu.org/archive/html/bug-coreutils/2006-10/msg00048.html>.
# But skip the test when cross-compiling, to prevent problems like the one
@@ -2715,6 +2727,7 @@ AC_DEFUN([_AC_LINK_IFELSE],
[$0_BODY])]dnl
[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])]dnl
[AS_IF([ac_fn_[]_AC_LANG_ABBREV[]_try_link "$LINENO"], [$2], [$3])
+m4_ifvaln([$4], [cp conftest.err "$4"])
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext[]m4_ifval([$1], [ conftest.$ac_ext])[]dnl
])# _AC_LINK_IFELSE
diff --git a/lib/autoconf/lang.m4 b/lib/autoconf/lang.m4
index 318f621..b14c4d3 100644
--- a/lib/autoconf/lang.m4
+++ b/lib/autoconf/lang.m4
@@ -729,3 +729,272 @@ ac_objext=$OBJEXT
AC_DEFUN([AC_LANG_WERROR],
[m4_divert_text([DEFAULTS], [ac_[]_AC_LANG_ABBREV[]_werror_flag=])
ac_[]_AC_LANG_ABBREV[]_werror_flag=yes])# AC_LANG_WERROR
+
+#
+# SYNOPSIS
+#
+# AC_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
+#
+# DESCRIPTION
+#
+# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
+# added in between.
+#
+# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
+# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
+# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
+# FLAG.
+#
+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
+# NOTE: Copied from AX_APPEND_FLAG in autoconf-archive, which had copyright
+# assigned as follows:
+#
+# Copyright (c) 2008 Guido U. Draheim <address@hidden>
+# Copyright (c) 2011 Maarten Bosmans <address@hidden>
+#
+
+#serial 2
+
+AC_DEFUN([AC_APPEND_FLAG],
+[AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl
+AS_VAR_SET_IF(FLAGS,
+ [case " AS_VAR_GET(FLAGS) " in
+ *" $1 "*)
+ AC_RUN_LOG([: FLAGS already contains $1])
+ ;;
+ *)
+ AC_RUN_LOG([: FLAGS="$FLAGS $1"])
+ AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"])
+ ;;
+ esac],
+ [AS_VAR_SET(FLAGS,["$1"])])
+AS_VAR_POPDEF([FLAGS])dnl
+])# AC_APPEND_FLAG
+
+#
+# SYNOPSIS
+#
+# AC_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
+# AC_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
+# AC_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
+#
+# DESCRIPTION
+#
+# Try to find a compiler option that enables most reasonable warnings.
+#
+# For the GNU compiler it will be -Wall. The result is added to the
+# shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default.
+#
+# Currently this macro knows about the GCC, Solaris, Digital Unix, AIX,
+# HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and
+# Intel compilers. For a given compiler, the Fortran flags are much more
+# experimental than their C equivalents.
+#
+# - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS
+# - $2 add-value-if-not-found : nothing
+# - $3 action-if-found : add value to shellvariable
+# - $4 action-if-not-found : nothing
+#
+# NOTE
+#
+# These macros depend on AX_APPEND_FLAG.
+#
+# NOTE
+#
+# Based upon AX_*FLAGS_WARN_ALL from autoconf-archive, which had copyright
+# assigned as follows:
+#
+# Copyright (c) 2008 Guido U. Draheim <address@hidden>
+# Copyright (c) 2010 Rhys Ulerich <address@hidden>
+#
+# NOTE (Implementation Tactics)
+#
+# The for-argument contains a list of options. The first part of
+# these does only exist to detect the compiler - usually it is
+# a global option to enable -ansi or -extrawarnings. All other
+# compilers will fail about it. That was needed since a lot of
+# compilers will give false positives for some option-syntax
+# like -Woption or -Xoption as they think of it is a pass-through
+# to later compile stages or something. The "%" is used as a
+# delimiter. A non-option comment can be given after "%%" marks
+# which will be shown but not added to the respective C/CXXFLAGS.
+
+#serial 14
+
+AC_DEFUN([AC_FLAGS_WARN_ALL],[dnl
+AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
+AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl
+AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for _AC_LANG compiler default warnings],
+VAR,[VAR="no, unknown"
+ac_save_[]FLAGS="$[]FLAGS"
+for ac_arg dnl
+in "-xHost % -Wall -w3" dnl Intel
+ "-pedantic -Wunreachable-code % -Wall -Wunreachable-code" dnl gcc/clang
+ "-pedantic % -Wall" dnl gcc when it no longer silently ignores
-Wunreachable-code
+ "-xstrconst % -v" dnl Solaris C
+ "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix
+ "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
+ "-ansi -ansiE % -fullwarn" dnl IRIX
+ "+ESlit % +w1" dnl HP-UX C
+ "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
+ "-h conform % -h msglevel 2" dnl Cray C (Unicos)
+ #
+do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
+ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
+ [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
+done
+FLAGS="$ac_save_[]FLAGS"
+AS_VAR_IF([enable_default_warning_flags],
+ [no],
+ [VAR="no, disabled per request"],
+ [VAR=m4_ifvaln($3,["no, disabled per request"],[$VAR])]
+ )
+])
+AS_VAR_POPDEF([FLAGS])dnl
+AC_REQUIRE([AC_APPEND_FLAG])
+case ".$VAR" in
+ .ok|.ok,*) m4_ifvaln($3,$3) ;;
+ .|.no|.no,*) m4_default($4,[m4_ifval($2,[AC_APPEND_FLAG([$2], [$1])])]) ;;
+ *) m4_default($3,[AC_APPEND_FLAG([$VAR], [$1])]) ;;
+esac
+AS_VAR_POPDEF([VAR])dnl
+])# AC_FLAGS_WARN_ALL
+
+
+# SYNOPSIS
+#
+# _AC_COMPILER_OPTION_IFELSE(OPTION, [IF-SUPPORTED], [IF-NOT-SUPPORTED])
+#
+# DESCRIPTION
+#
+# Check if the compiler supports OPTION when compiling and linking.
+# Executes IF-SUPPORTED if supported, and executes IF-NOT-SUPPORTED if a
+# non-zero exit status or option-specific stderr output occurs.
+#
+# NOTE
+#
+# Copied and modified from gnulib warnings.m4 module, which was authored by
+# Simon Josefsson
+AC_DEFUN([_AC_COMPILER_OPTION_IFELSE],
+[AS_VAR_PUSHDEF([ac_Warn], [ac_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl
+AS_VAR_PUSHDEF([ac_Flags], [_AC_LANG_PREFIX[][FLAGS]])dnl
+AS_LITERAL_IF([$1],
+ [m4_pushdef([ac_Positive], m4_bpatsubst([$1], [^-Wno-], [-W]))],
+ [ac_Positive="$1"
+case $ac_Positive in
+ -Wno-*) ac_Positive=-W`expr "X$ac_Positive" : 'X-Wno-\(.*\)'` ;;
+esac
+m4_pushdef([ac_Positive], [$ac_Positive])])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([ac_Warn]), [
+ ac_save_compiler_FLAGS="$ac_Flags"
+ AS_VAR_APPEND(m4_defn([ac_Flags]),
+ [" $ac_unknown_warnings_are_errors ]m4_defn([ac_Positive])["])
+ _AC_LINK_IFELSE([AC_LANG_PROGRAM],
+ [AS_VAR_SET([ac_Warn], [yes])],
+ [AS_VAR_SET([ac_Warn], [no])],
+ [conftest.err1])
+ ac_Flags="$ac_save_compiler_FLAGS"
+ AS_VAR_IF([ac_Warn], [yes], [
+ # This stderr output check is due to compilers like Intel icc/icpc that
+ # will only issue warnings to stderr for unknown flags, never exiting with
+ # non-zero status.
+ AS_VAR_PUSHDEF([ac_linecount1],
[ac_cv_linecount1_[]_AC_LANG_ABBREV[]_$1])dnl
+ ac_linecount1=`sed -n '$=' conftest.err1`
+ _AC_LINK_IFELSE([AC_LANG_PROGRAM], [], [], [conftest.err2])
+ AS_VAR_PUSHDEF([ac_linecount2],
[ac_cv_linecount2_[]_AC_LANG_ABBREV[]_$1])dnl
+ ac_linecount2=`sed -n '$=' conftest.err2`
+ AS_IF([test "$ac_linecount1" != "$ac_linecount2"],
+ [AS_VAR_PUSHDEF([ac_Pattern], [ac_cv_pattern_$1])dnl
+ ac_Pattern=`printf "%s " "$1" | sed ['s/[, ].*//']`
+ AS_IF([diff conftest.err1 conftest.err2 | grep -- "$ac_Pattern"
>/dev/null 2>&1],
+ [AS_VAR_SET([ac_Warn], [no])
+ AS_VAR_POPDEF([ac_Pattern])
+ ])
+ ])
+ AS_VAR_POPDEF([ac_linecount2])
+ AS_VAR_POPDEF([ac_linecount1])
+ ])
+])
+AS_VAR_IF([ac_Warn], [yes], [$2], [$3])
+rm -f conftest.err1 conftest.err2
+m4_popdef([ac_Positive])dnl
+AS_VAR_POPDEF([ac_Flags])dnl
+AS_VAR_POPDEF([ac_Warn])dnl
+])# _AC_COMPILER_OPTION_IFELSE
+
+# DESCRIPTION
+#
+# Forces LLVM compiler to complain about unknown flags.
+# Required by _AC_APPEND_FLAG_IFVALID.
+#
+# NOTE
+#
+# Copied and modified from gnulib warnings.m4 module, which was authored by
+# Simon Josefsson
+AC_DEFUN([_AC_UNKNOWN_WARNINGS_ARE_ERRORS],
+[# Clang doesn't complain about unknown warning options unless one also
+ # specifies -Wunknown-warning-option -Werror. Detect this.
+ _AC_COMPILER_OPTION_IFELSE([-Werror -Wunknown-warning-option],
+ [ac_unknown_warnings_are_errors='-Wunknown-warning-option -Werror'],
+ [ac_unknown_warnings_are_errors=])
+ ])# _AC_UNKNOWN_WARNINGS_ARE_ERRORS
+
+# SYNOPSIS
+#
+# AC_APPEND_CFLAG_IFVALID(OPTION)
+# AC_APPEND_CXXFLAG_IFVALID(OPTION)
+# AC_APPEND_FCFLAG_IFVALID(OPTION)
+#
+# DESCRIPTION
+#
+# Adds OPTION parameter to FLAGS if the compiler supports it when
+# compiling PROGRAM. For example, AC_APPENDFLAG_IFVALID([-Wparentheses]).
+#
+# NOTE
+#
+# Copied and modified from gnulib warnings.m4 module, which was authored by
+# Simon Josefsson
+AC_DEFUN([AC_APPEND_FLAG_IFVALID],[dnl
+AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
+AC_REQUIRE([_AC_UNKNOWN_WARNINGS_ARE_ERRORS])
+_AC_COMPILER_OPTION_IFELSE([$1],
+ [AC_APPEND_FLAG([$1])],
+ [])
+AS_VAR_POPDEF([FLAGS])dnl
+])# AC_APPEND_FLAG_IFVALID
+
+AC_DEFUN([AC_APPEND_CFLAG_IFVALID],[dnl
+AC_LANG_PUSH([C])
+AC_APPEND_FLAG_IFVALID([$1])
+AC_LANG_POP([C])
+])# AC_APPEND_CFLAG_IFVALID
+
+AC_DEFUN([AC_APPEND_CXXFLAG_IFVALID],[dnl
+AC_LANG_PUSH([C++])
+AC_APPEND_FLAG_IFVALID([$1])
+AC_LANG_POP([C++])
+])# AC_APPEND_CXXFLAG_IFVALID
+
+AC_DEFUN([AC_APPEND_FCFLAG_IFVALID],[dnl
+AC_LANG_PUSH([Fortran])
+AC_APPEND_FLAG_IFVALID([$1])
+AC_LANG_POP([Fortran])
+])# AC_APPEND_FCFLAG_IFVALID
+
+AC_DEFUN([AC_CFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([C])
+AC_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([C])
+])# AC_CFLAGS_WARN_ALL
+
+AC_DEFUN([AC_CXXFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([C++])
+AC_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([C++])
+])# AC_CXXFLAGS_WARN_ALL
+
+AC_DEFUN([AC_FCFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([Fortran])
+AC_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([Fortran])
+])# AC_FCFLAGS_WARN_ALL
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Turn on compiler warnings by default for AC_PROG_CC, AC_PROG_CXX & AC_PROG_FC,
Visser, Dale <=