RE: Turn on compiler warnings by default for AC_PROG_CC, AC_PROG_CXX & AC_PROG_FC
Dale Visser <[email protected]>
| Newsgroups | gmane.comp.sysutils.autoconf.patches |
|---|---|
| Message-ID | <[email protected]> |
> From: [email protected] > To: [email protected] > CC: [email protected] > Subject: Re: Turn on compiler warnings by default for AC_PROG_CC, AC_PROG_CXX & AC_PROG_FC > Date: Fri, 7 Feb 2014 10:20:50 -0500 > > The AC_APPEND_FLAG doesn't provide the functionality I would want for portability, > because it doesn't really check if the flag works (and it doesn't report the checking either). > For example, if I add this: > AC_APPEND_FLAG([-Wno-such-option], [CFLAGS]) > the "-Wno-such-option" is still passed to the compiler. Ugh. > > Perhaps you could change its functionality, or create a separate macro with that functionality. > That way, you could enable/disable warnings on compilers that accepted the flag... and > still work on compilers that didn't support it. > > Anyway, I think you're on the right path, just need some tweaks before it's ready. David: Your point is well-taken. Please find attached a revision of the earlier patch. This one includes AC_APPEND_*FLAG_IFVALID macros (* = C, CXX or FC) that will append flags to the compiler invocation only if a test compilation with those flags exits normally. In addition, I've made clarifications in the documentation about how to not add the newly default warning flags if desired, and I've standardized the informative printed output generated by the macros when configure is run. I think this change to the default behavior of AC_PROG_* (* = CC, CXX or FC) will help many projects using autoconf to become aware of issues in their code, ultimately helping to make it more reliable and secure. And as noted in the documentation changes, it is straightforward to restore the old, non-flag-adding behavior, as well as to add compiler flags you find useful for your particular code base. Best regards, Dale
merged_patch.diff
(application/octet-stream, 18 KB)
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 6795fcb..2c13296 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -7160,7 +7160,7 @@ makes this invalid. That is why Autoconf stopped issuing
@end table
@anchor{AC_PROG_CC}
-@defmac AC_PROG_CC (@ovar{compiler-search-list})
+@defmac AC_PROG_CC (@ovar{compiler-search-list}, @dots{})
@acindex{PROG_CC}
@evindex CC
@evindex CFLAGS
@@ -7213,6 +7213,17 @@ other compilers. If your package does not like this default, then it is
acceptable to insert the line @samp{: $@{CFLAGS=""@}} 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 parameters which will get shifted by 1,
+and passed on to @code{AC_FLAGS_WARN_ALL}. The following example adds a no-op
+fourth parameter, which becomes the third parameter to
+@code{AC_FLAGS_WARN_ALL}, suppressing the default addition of warning flags.
+
+@example
+AC_PROG_CC([], [], [], [:])
+@end 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.
@@ -7537,7 +7548,7 @@ compiler fix the header files automatically when installed.
@subsection C++ Compiler Characteristics
-@defmac AC_PROG_CXX (@ovar{compiler-search-list})
+@defmac AC_PROG_CXX (@ovar{compiler-search-list}, @dots{})
@acindex{PROG_CXX}
@evindex CXX
@evindex CXXFLAGS
@@ -7599,6 +7610,18 @@ 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{: $@{CXXFLAGS=""@}} 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 parameters which will get shifted by 1,
+and passed on to @code{AC_FLAGS_WARN_ALL}. The following example adds a no-op
+fourth parameter, which becomes the third parameter to
+@code{AC_FLAGS_WARN_ALL}, suppressing the default addition of warning flags.
+
+@example
+AC_PROG_CXX([], [], [], [:])
+@end example
+
@end defmac
@defmac AC_PROG_CXXCPP
@@ -7825,7 +7848,7 @@ The result of the GNU test is cached in the
@code{ac_cv_prog_f77_g} variable.
@end defmac
-@defmac AC_PROG_FC (@ovar{compiler-search-list}, @ovar{dialect})
+@defmac AC_PROG_FC (@ovar{compiler-search-list}, @ovar{dialect}, @dots{})
@acindex{PROG_FC}
@evindex FC
@evindex FCFLAGS
@@ -7863,6 +7886,19 @@ set @code{FCFLAGS} to @option{-g} for all other Fortran compilers.
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 parameters which will get shifted by 2,
+and passed on to @code{AC_FLAGS_WARN_ALL}. The following example adds a no-op
+fifth parameter, which becomes the third parameter to
+@code{AC_FLAGS_WARN_ALL}, suppressing the default addition of warning flags.
+
+@example
+AC_PROG_FC([], [], [], [], [:])
+@end example
+
+
@end defmac
@defmac AC_PROG_F77_C_O
@@ -23444,6 +23480,127 @@ The current language does not change. @code{AC_LANG_PUSH} is preferred
(@pxref{AC_LANG_PUSH}).
@end defmac
+@anchor{AC_CFLAGS_WARN_ALL}
+@defmac 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})
+@acindex{CFLAGS_WARN_ALL}
+Try to find a C 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.
+
+@example
+AC_CFLAGS_WARN_ALL
+@end example
+@end defmac
+
+@anchor{AC_CXXFLAGS_WARN_ALL}
+@defmac 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})
+@acindex{CXXFLAGS_WARN_ALL}
+Try to find a C++ 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.
+
+@example
+AC_CXXFLAGS_WARN_ALL
+@end example
+@end defmac
+
+@anchor{AC_FCFLAGS_WARN_ALL}
+@defmac 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})
+@acindex{FCFLAGS_WARN_ALL}
+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.
+
+@example
+AC_FCFLAGS_WARN_ALL
+@end example
+@end defmac
+
+@anchor{AC_FLAGS_WARN_ALL}
+@defmac 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})
+@acindex{FLAGS_WARN_ALL}
+Try to find a compiler option that enables most reasonable warnings.
+
+Usually not used directly. Instead, use @pxref{AC_CFLAGS_WARN_ALL},
+@pxref{AC_CXXFLAGS_WARN_ALL}, 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.
+
+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.
+@end defmac
+
+@anchor{AC_APPEND_FLAG}
+@defmac AC_APPEND_FLAG(@var{add-value})
+@acindex{APPEND_FLAG}
+Used internally by @pxref{AC_FLAGS_WARN_ALL}. Behavior is to append the given to
+the shell variable determined or provided in the call to
+@pxref{AC_FLAGS_WARN_ALL}, but only if it is not already present there.
+@end defmac
+
+@anchor{AC_APPEND_CFLAG_IFVALID}
+@defmac AC_APPEND_CFLAG_IFVALID(@var{add-value})
+@acindex{APPEND_CFLAG_IFVALID}
+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.
+
+@example
+AC_PROG_CC
+AC_APPEND_CFLAG_IFVALID([-Wfancy-warnings])
+@end example
+
+@end defmac
+
+@anchor{AC_APPEND_CXXFLAG_IFVALID}
+@defmac AC_APPEND_CXXFLAG_IFVALID(@var{add-value})
+@acindex{APPEND_CXXFLAG_IFVALID}
+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.
+
+@example
+AC_PROG_CXX
+AC_APPEND_CXXFLAG_IFVALID([-Wfancy-warnings])
+@end example
+
+@end defmac
+
+@anchor{AC_APPEND_FCFLAG_IFVALID}
+@defmac AC_APPEND_FCFLAG_IFVALID(@var{add-value})
+@acindex{APPEND_FCFLAG_IFVALID}
+Sets the current language to Fortran, 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 Fortran
+compiler, but only if @option{-Wfancy-warnings} is a valid flag.
+
+@example
+AC_PROG_FC
+AC_APPEND_FCFLAG_IFVALID([-Wfancy-warnings])
+@end example
+@end defmac
+
+@anchor{AC_APPEND_FLAG_IFVALID}
+@defmac AC_APPEND_FLAG_IFVALID(@var{add-value})
+@acindex{APPEND_FLAG_IFVALID}
+Used internally by @pxref{AC_APPEND_CFLAG_IFVALID},
+@pxref{AC_APPEND_CXXFLAG_IFVALID}, and @pxref{AC_APPEND_FCFLAG_IFVALID}.
+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}.
+@end defmac
+
@defmac AC_LINK_FILES (@var{source}@dots{}, @var{dest}@dots{})
@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 f0f6667..0731202 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -424,11 +424,17 @@ AU_DEFUN([ac_cv_prog_gcc],
[ac_cv_c_compiler_gnu])
-# AC_PROG_CC([COMPILER ...])
+# AC_PROG_CC([COMPILER ...], ...)
# --------------------------
# 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.
+# Any extra parameters will be passed on to AC_FLAGS_WARN_ALL. If there
+# are no extra parameters, then compiler warnings will be turned on. An
+# example of how to avoid this is invoking
+# AC_PROG_CC([COMPILER ...], [], [], [echo No extra warnings please.])
+# Where the final parameter is providing an alternate action to enabling
+# warning flags.
AN_MAKEVAR([CC], [AC_PROG_CC])
AN_PROGRAM([cc], [AC_PROG_CC])
AN_PROGRAM([gcc], [AC_PROG_CC])
@@ -491,6 +497,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(m4_shift($@))
AC_LANG_POP(C)dnl
])# AC_PROG_CC
@@ -674,7 +681,7 @@ AU_DEFUN([ac_cv_prog_gxx],
[ac_cv_cxx_compiler_gnu])
-# AC_PROG_CXX([LIST-OF-COMPILERS])
+# AC_PROG_CXX([LIST-OF-COMPILERS], ...)
# --------------------------------
# LIST-OF-COMPILERS is a space separated list of C++ compilers to search
# for (if not specified, a default list is used). This just gives the
@@ -686,6 +693,12 @@ AU_DEFUN([ac_cv_prog_gxx],
# RCC Rational C++
# xlC_r AIX C Set++ (with support for reentrant code)
# xlC AIX C Set++
+# Any extra parameters will be passed on to AC_FLAGS_WARN_ALL. If there
+# are no extra parameters, then compiler warnings will be turned on. An
+# example of how to avoid this is invoking
+# AC_PROG_CXX([LIST-OF-COMPILERS], [], [], [echo No extra warnings please.])
+# Where the final parameter is providing an alternate action to enabling
+# warning flags.
AN_MAKEVAR([CXX], [AC_PROG_CXX])
AN_PROGRAM([CC], [AC_PROG_CXX])
AN_PROGRAM([c++], [AC_PROG_CXX])
@@ -732,6 +745,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(m4_shift($@))
AC_LANG_POP(C++)dnl
])# AC_PROG_CXX
diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4
index e0f66f1..e013d28 100644
--- a/lib/autoconf/fortran.m4
+++ b/lib/autoconf/fortran.m4
@@ -371,10 +371,16 @@ AC_LANG_POP(Fortran 77)dnl
])# AC_PROG_F77
-# AC_PROG_FC([COMPILERS...], [DIALECT])
+# AC_PROG_FC([COMPILERS...], [DIALECT], ...)
# -------------------------------------
# COMPILERS is a space separated list of Fortran 77 compilers to search
# for, and [DIALECT] is an optional dialect. See also _AC_PROG_FC.
+# Any extra parameters will be passed on to AC_FLAGS_WARN_ALL. If there
+# are no extra parameters, then compiler warnings will be turned on. An
+# example of how to avoid this is invoking
+# AC_PROG_FC([COMPILERS...], [DIALECT], [], [], [echo No extra warnings please.])
+# Where the final parameter is providing an alternate action to enabling
+# warning flags.
AC_DEFUN([AC_PROG_FC],
[AC_LANG_PUSH(Fortran)dnl
AC_ARG_VAR([FC], [Fortran compiler command])dnl
@@ -387,6 +393,7 @@ if test $ac_compiler_gnu = yes; then
else
GFC=
fi
+AC_FLAGS_WARN_ALL(m4_shift2($@))
AC_LANG_POP(Fortran)dnl
])# AC_PROG_FC
diff --git a/lib/autoconf/lang.m4 b/lib/autoconf/lang.m4
index b8cbe76..cbff0f4 100644
--- a/lib/autoconf/lang.m4
+++ b/lib/autoconf/lang.m4
@@ -719,3 +719,183 @@ 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 <[email protected]>
+# Copyright (c) 2011 Maarten Bosmans <[email protected]>
+#
+
+#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
+])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 (and -ansi -pedantic) 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 <[email protected]>
+# Copyright (c) 2010 Rhys Ulerich <[email protected]>
+#
+
+#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 maximum warnings],
+VAR,[VAR="no, unknown"
+ac_save_[]FLAGS="$[]FLAGS"
+for ac_arg dnl
+in "-warn all % -warn all" dnl Intel
+ "-pedantic % -Wall" dnl GCC
+ "-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"
+VAR=m4_ifvaln($3,[ignored],[$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
+])dnl AC_FLAGS_WARN_ALL
+dnl implementation tactics:
+dnl the for-argument contains a list of options. The first part of
+dnl these does only exist to detect the compiler - usually it is
+dnl a global option to enable -ansi or -extrawarnings. All other
+dnl compilers will fail about it. That was needed since a lot of
+dnl compilers will give false positives for some option-syntax
+dnl like -Woption or -Xoption as they think of it is a pass-through
+dnl to later compile stages or something. The "%" is used as a
+dnl delimiter. A non-option comment can be given after "%%" marks
+dnl which will be shown but not added to the respective C/CXXFLAGS.
+
+#
+# SYNOPSIS
+#
+# AC_APPEND_FLAG_IFVALID(FLAG)
+#
+# DESCRIPTION
+#
+# FLAG is tested as a compile flag. If the exit code is 0 for the text,
+# then it is appended to the flags.
+AC_DEFUN([AC_APPEND_FLAG_IFVALID],[dnl
+AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
+AC_MSG_CHECKING([validity of $1 in FLAGS])
+AFIV_TMP="no, unknown"
+ac_save_[]FLAGS="$[]FLAGS"
+FLAGS=$1
+_AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [AFIV_TMP="$1"])
+FLAGS="$ac_save_[]FLAGS"
+AS_VAR_POPDEF([FLAGS])dnl
+AC_REQUIRE([AC_APPEND_FLAG])
+case ".$AFIV_TMP" in
+ .|.no|.no,*) AC_MSG_RESULT([no]) ;;
+ *) AC_APPEND_FLAG([$1]) AC_MSG_RESULT([yes]) ;;
+esac
+])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_DEFUN([AC_APPEND_CXXFLAG_IFVALID],[dnl
+AC_LANG_PUSH([C++])
+AC_APPEND_FLAG_IFVALID([$1])
+AC_LANG_POP([C++])
+])
+
+AC_DEFUN([AC_APPEND_FCFLAG_IFVALID],[dnl
+AC_LANG_PUSH([Fortran])
+AC_APPEND_FLAG_IFVALID([$1])
+AC_LANG_POP([Fortran])
+])
+
+AC_DEFUN([AC_CFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([C])
+AC_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([C])
+])
+
+AC_DEFUN([AC_CXXFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([C++])
+AC_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([C++])
+])
+
+AC_DEFUN([AC_FCFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([Fortran])
+AC_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([Fortran])
+])