[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] warn: new special syntax warning, hack for aclocal (was: Re: [PA
From: |
Stefano Lattarini |
Subject: |
[PATCH] warn: new special syntax warning, hack for aclocal (was: Re: [PATCH 0/2] AC_CONFIG_MACRO_DIRS: implementation and documentation) |
Date: |
Fri, 02 Nov 2012 20:49:59 +0100 |
Reference:
<http://lists.gnu.org/archive/html/autoconf-patches/2012-11/msg00004.html>
On 11/02/2012 07:34 PM, Stefano Lattarini wrote:
> Well, it turns out that such warnings are coming from the autom4te
> invocation, so I see no simple, non-hacky way to avoid them, unless
> we add a knob to autom4te itself.
>
> So, autoconfers: would be OK with you to add a new warning "category"
> to autom4te that would suppress *only* this specific warning?
> The warning in question being
>
> AC_FOO is m4_require'd but not m4_defun'd
>
> that is emitted by the '_m4_require_call' internal macro (defined in
> 'lib/m4sugar/m4sugar.m4').
>
Oh well, I went on and wrote a patch anyway. It should be good to go,
maybe modulo the name of the new "singleton" warnings category; if anyone
has a better name to suggest, shoot!
Regards,
Stefano
---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ----
>From f5f17fa1b2bccdd29101f7eb1eefe8c4dabe4ad3 Mon Sep 17 00:00:00 2001
Message-Id: <address@hidden>
From: Stefano Lattarini <address@hidden>
Date: Fri, 2 Nov 2012 20:14:53 +0100
Subject: [PATCH] warn: new special syntax warning, hack for aclocal
We introduce a new special warning category, "m4require-without-m4defun",
meant to contain only those warnings caused m4 macros that m4_require'd
but not m4_defun'd. This category is automatically implied by '-Wsyntax',
but can be disabled without disabling the other warnings in the "syntax"
category.
This new category is introduced exclusively to allow aclocal to process
AC_CONFIG_MACRO_DIRS without emitting spurious warnings. In fact, if
aclocal doesn't suppress that special warnings, then, when some macro
expanded in configure.ac calls AC_REQUIRE on another macro that is defined
in one of the local m4 macro dirs specified with AC_CONFIG_MACRO_DIRS, the
*first* autom4te invocation issued by aclocal, not yet being able to "see"
the m4 macro definitions in the local m4 dirs, will prints spurious
warnings like:
configure.ac:4: warning: MY_BAR is m4_require'd but not m4_defun'd
configure.ac:3: MY_FOO is expanded from...
Expose this weakness in our testsuite.
Originally reported by Nick Bowler; see point (4) of:
<http://lists.gnu.org/archive/html/autoconf-patches/2012-11/msg00000.html>
* lib/Autom4te/ChannelDefs.pm (m4require-without-m4defun): New channel,
enabled by default.
(switch_warning): Special handling for it: silence it when '-Wno-syntax'
is given, enable it when '-Wsyntax' is given.
* lib/m4sugar/m4sugar.m4 (_m4_require_call): Give warnings in the new
"m4require-without-m4defun" category, rather than in the 'syntax' one.
* tests/m4sugar.at (m4@&address@hidden): Enhance.
Signed-off-by: Stefano Lattarini <address@hidden>
---
lib/Autom4te/ChannelDefs.pm | 14 ++++++++++++++
lib/m4sugar/m4sugar.m4 | 7 ++++++-
tests/m4sugar.at | 21 +++++++++++++++++++++
3 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/lib/Autom4te/ChannelDefs.pm b/lib/Autom4te/ChannelDefs.pm
index 0d5b5c4..af67059 100644
--- a/lib/Autom4te/ChannelDefs.pm
+++ b/lib/Autom4te/ChannelDefs.pm
@@ -152,6 +152,11 @@ register_channel 'obsolete', type => 'warning', silent =>
1;
register_channel 'override', type => 'warning', silent => 1;
register_channel 'portability', type => 'warning', silent => 1;
register_channel 'syntax', type => 'warning';
+# Special kind of syntax error that we must be able to silence
+# individually in order to support AC_CONFIG_MACRO_DIRS in aclocal.
+# For more background, see:
+# http://lists.gnu.org/archive/html/autoconf-patches/2012-11/msg00004.html
+register_channel 'm4require-without-m4defun', type => 'warning';
register_channel 'unsupported', type => 'warning';
register_channel 'verb', type => 'debug', silent => 1, ordered => 0;
@@ -274,6 +279,15 @@ sub switch_warning ($)
elsif (channel_type ($cat) eq 'warning')
{
setup_channel $cat, silent => $has_no;
+ # Handling of syntax warnings is trickier, due to the hack
+ # necessary to support AC_CONFIG_MACRO_DIRS in aclocal.
+ if ($cat eq 'syntax')
+ {
+ # '-Wsyntax' must enable warnings in the "hack" category
+ # 'm4require-without-m4defun', while '-Wno-syntax' must
+ # disable them.
+ setup_channel 'm4require-without-m4defun', silent => $has_no;
+ }
}
else
{
diff --git a/lib/m4sugar/m4sugar.m4 b/lib/m4sugar/m4sugar.m4
index 12a9ab7..c1b1029 100644
--- a/lib/m4sugar/m4sugar.m4
+++ b/lib/m4sugar/m4sugar.m4
@@ -2080,13 +2080,18 @@ m4_if([$0], [m4_require], [[m4_defun]],
[[AC_DEFUN]])['d macro])])]dnl
#
# This is called frequently, so minimize the number of macro invocations
# by avoiding dnl and other overhead on the common path.
+# The use of convoluted warning category 'm4require-without-m4defun' is
+# an hack required by aclocal to support AC_CONFIG_MACRO_DIRS without
+# risking spurious warnings; for more background, see:
+# http://lists.gnu.org/archive/html/autoconf-patches/2012-11/msg00004.html
m4_define([_m4_require_call],
[m4_pushdef([_m4_divert_grow], m4_decr(_m4_divert_grow))]dnl
[m4_pushdef([_m4_diverting([$1])])m4_pushdef([_m4_diverting], [$1])]dnl
[m4_divert_push(_m4_divert_grow, [-])]dnl
[m4_if([$2], [], [$1], [$2])
m4_provide_if([$1], [m4_set_remove([_m4_provide], [$1])],
- [m4_warn([syntax], [$1 is m4_require'd but not m4_defun'd])])]dnl
+ [m4_warn([m4require-without-m4defun],
+ [$1 is m4_require'd but not m4_defun'd])])]dnl
[_m4_divert_raw($3)_m4_undivert(_m4_divert_grow)]dnl
[m4_divert_pop(_m4_divert_grow)_m4_popdef([_m4_divert_grow],
[_m4_diverting([$1])], [_m4_diverting])])
diff --git a/tests/m4sugar.at b/tests/m4sugar.at
index 997e2dd..5b91287 100644
--- a/tests/m4sugar.at
+++ b/tests/m4sugar.at
@@ -254,12 +254,14 @@ cross_warning[]dnl
m4_warn([syntax], [syntax])dnl
cross_warning[]dnl
m4_warn([syntax], [syntax])dnl
+m4_warn([m4require-without-m4defun], [hack for aclocal])dnl
]])
AT_CHECK_M4SUGAR([-o-], 0, [],
[script.4s:4: warning: prefer named diversions
script.4s:7: warning: syntax
script.4s:9: warning: syntax
+script.4s:10: warning: hack for aclocal
])
AT_CHECK_M4SUGAR([-o- -Wall], 0, [],
@@ -273,6 +275,7 @@ script.4s:8: warning: cross
script.4s:2: cross_warning is expanded from...
script.4s:8: the top level
script.4s:9: warning: syntax
+script.4s:10: warning: hack for aclocal
])
AT_CHECK_M4SUGAR([-o- -Wnone,cross], 0, [],
@@ -293,6 +296,24 @@ script.4s:2: cross_warning is expanded from...
script.4s:8: the top level
]])
+AT_CHECK_M4SUGAR([-o- -Wnone -Wsyntax], 0, [],
+[script.4s:4: warning: prefer named diversions
+script.4s:7: warning: syntax
+script.4s:9: warning: syntax
+script.4s:10: warning: hack for aclocal
+])
+
+AT_CHECK_M4SUGAR([-o- -Wnone -Wm4require-without-m4defun], 0, [],
+[script.4s:10: warning: hack for aclocal
+])
+
+AT_CHECK_M4SUGAR([-o- -Werror,none,syntax,no-m4require-without-m4defun],
+ 1, [],
+[script.4s:4: warning: prefer named diversions
+script.4s:7: warning: syntax
+script.4s:9: warning: syntax
+])
+
AT_CLEANUP
--
1.8.0
- Re: [PATCH 0/2] AC_CONFIG_MACRO_DIRS: implementation and documentation, Nick Bowler, 2012/11/01
- Re: [PATCH 0/2] AC_CONFIG_MACRO_DIRS: implementation and documentation, Stefano Lattarini, 2012/11/02
- Message not available
- Re: [PATCH 0/2] AC_CONFIG_MACRO_DIRS: implementation and documentation, Nick Bowler, 2012/11/02
- Re: [PATCH 0/2] AC_CONFIG_MACRO_DIRS: implementation and documentation, Stefano Lattarini, 2012/11/02
- Re: [PATCH 0/2] AC_CONFIG_MACRO_DIRS: implementation and documentation, Stefano Lattarini, 2012/11/02
- [PATCH] warn: new special syntax warning, hack for aclocal (was: Re: [PATCH 0/2] AC_CONFIG_MACRO_DIRS: implementation and documentation),
Stefano Lattarini <=
- Re: [PATCH] warn: new special syntax warning, hack for aclocal, Eric Blake, 2012/11/02
- Re: [PATCH] warn: new special syntax warning, hack for aclocal, Stefano Lattarini, 2012/11/02
- Re: [PATCH 0/2] AC_CONFIG_MACRO_DIRS: implementation and documentation, Eric Blake, 2012/11/02