[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Stack-like AC_LANG_WERROR
From: |
Andrey Simonenko |
Subject: |
Stack-like AC_LANG_WERROR |
Date: |
Fri, 11 May 2007 13:49:34 +0300 |
User-agent: |
Mutt/1.5.15 (2007-04-06) |
Hello,
I propose to change AC_LANG_WERROR in the following backward
compatible way:
1. No arguments:
Similarly to AC_LANG_WERROR([on])
2. One argument:
on -- treat warnings as fatal errors + remember previous value;
off -- do not treat warnings as fatal errors + remember previous value;
pop -- restore previous value.
Each language has own stack of AC_LANG_WERROR settings (first `off'
in a stack is the default value):
AC_LANG([C])
AC_LANG_WERROR([on]) # c_werror=yes C stack: off
AC_LANG_WERROR([off]) # c_werror= C stack: on off
AC_LANG_WERROR([off]) # c_werror= C stack: off on off
AC_LANG([C++])
AC_LANG_WERROR([on]) # cxx_werror=yes C++ stack: off
AC_LANG_WERROR([on]) # cxx_werror=yes C++ stack: on off
AC_LANG([C])
AC_LANG_WERROR([pop]) # c_werror= C stack: on off
AC_LANG_WERROR([pop]) # c_werror=yes C stack: off
A stack of settings for each language is implemented with
_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG variables.
If `on/off' and `pop' calls are unbalanced, then the following
error is outputted:
configure.ac:6: error: AC_LANG_WERROR: unbalanced number of `on/off'
and `pop' calls for C
In addition to this modification of AC_LANG_WERROR, all manually
changed ac_x_werror_flag variables in all .m4 files should be changed
to appropriate AC_LANG_WERROR calls.
Here is indented version of AC_LANG_WERROR:
AC_DEFUN([AC_LANG_WERROR],
[
m4_ifdef(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG, [], [
m4_divert_text([DEFAULTS], [
m4_define(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG, [off])
ac_[]_AC_LANG_ABBREV[]_werror_flag=])])
m4_if(
$#, 1, [m4_if(
[$1], [on], [
m4_pushdef(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG, [on])
ac_[]_AC_LANG_ABBREV[]_werror_flag=yes],
[$1], [off], [
m4_pushdef(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG, [off])
ac_[]_AC_LANG_ABBREV[]_werror_flag=],
[$1], [pop], [
m4_popdef(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG)
m4_ifdef(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG, [],
[m4_fatal([$0: unbalanced number of `on/off' and `pop' calls
for] _AC_LANG)])
m4_if(
m4_defn(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG), [on],
[ac_[]_AC_LANG_ABBREV[]_werror_flag=yes],
m4_defn(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG), [off],
[ac_[]_AC_LANG_ABBREV[]_werror_flag=],
[m4_fatal([$0: stack of values is damaged])])],
[m4_fatal([$0: wrong argument: `$1'])])],
$#, 0, [AC_LANG_WERROR([on])],
[m4_fatal([$0: incorrect number of arguments: $#])])
])# AC_LANG_WERROR
Here is a patch:
lang.m4.diff:
--- lang.m4.orig Fri Oct 6 20:43:55 2006
+++ lang.m4 Sat Apr 14 19:41:22 2007
@@ -662,10 +662,40 @@
## 4. Compilers' characteristics. ##
## ------------------------------- ##
-# AC_LANG_WERROR
-# ------------------
-# Treat warnings from the current language's preprocessor, compiler, and
-# linker as fatal errors.
+# AC_LANG_WERROR([VALUE])
+# -----------------------
+# How to treat warnings from the current language's preprocessor, compiler,
+# and linker (works in a stack-like fashion):
+# 1. No arguments:
+# Similarly to AC_LANG_WERROR([on])
+# 2. One argument:
+# on -- treat warnings as fatal errors + remember previous value;
+# off -- do not treat warnings as fatal errors + remember previous value;
+# pop -- restore previous value.
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
+[m4_ifdef(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG, [], [dnl
+m4_divert_text([DEFAULTS],
+[m4_define(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG, [off])dnl
+ac_[]_AC_LANG_ABBREV[]_werror_flag=])])dnl
+m4_if(
+$#, 1, [m4_if(
+[$1], [on], [dnl
+m4_pushdef(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG, [on])dnl
+ac_[]_AC_LANG_ABBREV[]_werror_flag=yes],
+[$1], [off], [dnl
+m4_pushdef(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG, [off])dnl
+ac_[]_AC_LANG_ABBREV[]_werror_flag=],
+[$1], [pop], [dnl
+m4_popdef(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG)dnl
+m4_ifdef(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG, [],
+[m4_fatal([$0: unbalanced number of `on/off' and `pop' calls for]
_AC_LANG)])dnl
+m4_if(
+m4_defn(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG), [on],
+[ac_[]_AC_LANG_ABBREV[]_werror_flag=yes],
+m4_defn(_AC_LANG_[]_AC_LANG_ABBREV[]_WERROR_FLAG), [off],
+[ac_[]_AC_LANG_ABBREV[]_werror_flag=],
+[m4_fatal([$0: stack of values is damaged])])],
+[m4_fatal([$0: wrong argument: `$1'])])],
+$#, 0, [AC_LANG_WERROR([on])],
+[m4_fatal([$0: incorrect number of arguments: $#])])[]dnl
+])# AC_LANG_WERROR
autoconf.texi.diff:
--- autoconf.texi.orig Fri Nov 17 02:16:27 2006
+++ autoconf.texi Fri Apr 13 10:29:05 2007
@@ -6250,13 +6250,23 @@
Execute @var{action-if-fails} if the value cannot be determined correctly.
@end defmac
address@hidden AC_LANG_WERROR
address@hidden AC_LANG_WERROR (@ovar{value})
@acindex{LANG_WERROR}
Normally Autoconf ignores warnings generated by the compiler, linker, and
-preprocessor. If this macro is used, warnings count as fatal
-errors for the current language. This macro is useful when the
-results of configuration are used where warnings are unacceptable; for
-instance, if parts of a program are built with the @acronym{GCC}
+preprocessor. This macro allows to change this behaviour in a stack-like
+fashion. If @var{value} is @code{on} or if an optional argument is not
+given, then warnings are treated as fatal errors for the current language.
+If @var{value} is @code{off}, then the normal Autoconf's behaviour for
+the current language is restored. Each macro call with @code{on} or
address@hidden value remembers current settings on a stack and sets new
+settings for the current language. Each language has own stack that
+is used exclusively by this macro for saving and restoring settings.
+If @var{value} is @code{pop}, then settings, that are saved on the top
+of the stack, are restored and are removed from the stack.
+
+This macro is useful when the results of configuration are used where
+warnings are unacceptable; for instance, if parts of a program are built
+with the @acronym{GCC}
@option{-Werror}
option. If the whole program is built using @option{-Werror} it is
often simpler to put @option{-Werror} in the compiler flags (@code{CFLAGS},
Changelog:
2007-05-11 Andrey Simonenko <address@hidden>
* lib/autoconf/lang.m4 (AC_LANG_WERROR): Accept an optional argument
on/off/pop and work in a stack-like fashion.
* doc/autoconf.texi (Generic Compiler Characteristics): Document
AC_LANG_WERROR changes.
- Stack-like AC_LANG_WERROR,
Andrey Simonenko <=