autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: Cached warnings


From: Akim Demaille
Subject: FYI: Cached warnings
Date: Thu, 21 Aug 2003 19:21:57 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        First stab at preserving warnings between calls to autom4te,
        including when the cache is used.

        There are still several issues: (i) there are too many runs of m4
        (one for include, one for warnings, and some more), (ii) warnings
        spreading on several lines are not handled gracefully, (iii) the
        code meant to have the call stack display for errors does not work
        (its handling should move from m4 to autom4te).

        * bin/autom4te.in Autom4te::Channels, Autom4te::ChannelDefs):
        Use them.
        (@preselect): Add m4_warn.
        ($exit_status): Remove, use $exit_code.
        ($help): Use Autom4te::ChannelDefs::usage.
        (&handle_m4): No longer define the m4_warnings.
        At each run, extract and report the warnings.
        Always cache the result, including if the exit status is on
        failure, since if nothing changes, we should result in the same
        failure, hence we can use the cache.
        * lib/m4sugar/m4sugar.m4 (m4_warning_ifelse, _m4_warning_ifelse)
        (_m4_warning_error_ifelse, __m4_warning_error_ifelse, _m4_warn):
        Remove.
        (m4_warn): Redefine as a do-nothing: it is its invocation that
        matters, as warnings are now reported via traces.
        * lib/autoconf/general.m4 (AC_DIAGNOSE): Don't make it a copy of
        the contents of m4_warn: make it _call_ m4_warn, so that tracing
        the latter reveals calls to the former.

        Adjust the tests.

        * tests/m4sugar.at (m4@&address@hidden): Use existing warning 
categories.

Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.302
diff -u -u -r1.302 NEWS
--- NEWS 23 Jun 2003 11:11:41 -0000 1.302
+++ NEWS 21 Aug 2003 17:19:17 -0000
@@ -3,6 +3,11 @@
 ** Autotest and local.at
   The optional file local.at is always included in Autotest test suites.
 
+** Warnings
+  The warnings are always issued, including with cached runs.
+  This became a significant problem since aclocal and automake can
+  run autoconf behind the scene.
+
 * Major changes in Autoconf 2.57a
 
   Released 2003-06-20 by Akim Demaille.
Index: configure
===================================================================
RCS file: /cvsroot/autoconf/autoconf/configure,v
retrieving revision 1.242
diff -u -u -r1.242 configure
--- configure 20 Aug 2003 06:29:55 -0000 1.242
+++ configure 21 Aug 2003 17:19:17 -0000
@@ -23,7 +23,7 @@
 fi
 
 # Support unset when possible.
-if (as_foo=foo; unset as_foo) >/dev/null 2>&1; then
+if ((MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   as_unset=unset
 else
   as_unset=false
@@ -2118,7 +2118,7 @@
 fi
 
 # Support unset when possible.
-if (as_foo=foo; unset as_foo) >/dev/null 2>&1; then
+if ((MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   as_unset=unset
 else
   as_unset=false
Index: bin/autom4te.in
===================================================================
RCS file: /cvsroot/autoconf/autoconf/bin/autom4te.in,v
retrieving revision 1.85
diff -u -u -r1.85 autom4te.in
--- bin/autom4te.in 20 Aug 2003 12:52:18 -0000 1.85
+++ bin/autom4te.in 21 Aug 2003 17:19:18 -0000
@@ -236,6 +236,8 @@
 
 package Autom4te;
 
+use Autom4te::ChannelDefs;
+use Autom4te::Channels;
 use Autom4te::FileUtils;
 use Autom4te::General;
 use File::Basename;
@@ -273,17 +275,13 @@
 # `m4_pattern_allow' to check the output.
 #
 # FIXME: What about `sinclude'?
-my @preselect = ('include', 'm4_pattern_allow', 'm4_pattern_forbid');
-
-# List of warnings.
-my @warning;
+my @preselect = ('include',
+                'm4_pattern_allow', 'm4_pattern_forbid',
+                'm4_warn');
 
 # M4 include path.
 my @include;
 
-# 0 for EXIT_SUCCESS.
-my $exit_status = 0;
-
 # Do we freeze?
 my $freeze = 0;
 
@@ -356,8 +354,7 @@
 
 # $HELP
 # -----
-$help = << "EOF";
-Usage: $0 [OPTION] ... [FILES]
+$help = "Usage: $0 [OPTION] ... [FILES]
 
 Run GNU M4 on the FILES, avoiding useless runs.  Output the traces if tracing,
 the frozen file if freezing, otherwise the expansion of the FILES.
@@ -391,14 +388,7 @@
   \`M4sh\'       create M4sh shell scripts
   \`M4sugar\'    create M4sugar output
 
-Warning categories include:
-  \`cross\'         cross compilation issues
-  \`obsolete\'      obsolete constructs
-  \`syntax\'        dubious syntactic constructs
-  \`all\'           all the warnings
-  \`no-CATEGORY\'   turn off the warnings on CATEGORY
-  \`none\'          turn off all the warnings
-  \`error\'         warnings are error
+" . Autom4te::ChannelDefs::usage . "
 
 The environment variable \`WARNINGS\' is honored.
 
@@ -414,7 +404,7 @@
   -F, --freeze   produce an M4 frozen state file for FILES
 
 Report bugs to <address@hidden>.
-EOF
+";
 
 # $VERSION
 # --------
@@ -540,11 +530,12 @@
   # Process the arguments for real this time.
   my @trace;
   my @prepend_include;
+  parse_WARNINGS;
   getopt
     (
      # Operation modes:
      "o|output=s"   => \$output,
-     "W|warnings=s" => address@hidden,
+     "W|warnings=s" => \&parse_warnings,
      "m|mode=s"     => \$mode,
      "M|melt"       => \$melt,
 
@@ -656,13 +647,6 @@
 {
   my ($req, @macro) = @_;
 
-  # The warnings are the concatenation of 1. application's defaults,
-  # 2. $WARNINGS, $3 command line options, in that order.
-  # Set them in the order expected by the M4 macros: the converse.
-  my $m4_warnings =
-    lc join (',', reverse (split (',', ($ENV{'WARNINGS'} || '')),
-                          map { split /,/ } @warning));
-
   # GNU m4 appends when using --error-output.
   unlink ($tcache . $req->id . "t");
 
@@ -674,7 +658,6 @@
   # when we are interrupted (that leaves corrupted files).
   xsystem ("$m4"
           . join (' --include=', '', @include)
-          . " --define=m4_warnings=$m4_warnings"
           . ' --debug=aflq'
           . (!exists $ENV{'AUTOM4TE_NO_FATAL'} ? ' --fatal-warning' : '')
           . " --error-output=$tcache" . $req->id . "t"
@@ -805,7 +788,7 @@
   # This is unsatisfying but...
   my $prohibited = '\b(' . join ('|', keys %prohibited) . ')\b';
   my $file = new Autom4te::XFile ($ARGV[$#ARGV]);
-  $exit_status = 1;
+  $exit_code = 1;
 
   while ($_ = $file->getline)
     {
@@ -1207,6 +1190,15 @@
 handle_m4 ($req, keys %{$req->macro})
   if $force || ! $req->valid;
 
+# Issue the warnings each time autom4te was run.
+handle_traces ($req, "$tmp/warnings",
+              ('m4_warn' => "\$1::\$f:\$l::\$2\n\n"));
+for (split (/\n{2,}/, contents ("$tmp/warnings")))
+{
+  my ($cat, $loc, $msg) = split '::';
+  msg $cat, $loc, "warning: $msg";
+}
+
 # Now output...
 if (%trace)
   {
@@ -1225,13 +1217,11 @@
       if mtime ($output) < mtime ($ocache . $req->id);
   }
 
-# If all went fine, the cache is valid.
-$req->valid (1)
-  if $exit_status == 0;
-
+# If we ran up to here, the cache is valid.
+$req->valid (1);
 Request->save ($icache_file);
 
-exit $exit_status;
+exit $exit_code;
 
 ### Setup "GNU" style for perl-mode and cperl-mode.
 ## Local Variables:
Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.816
diff -u -u -r1.816 general.m4
--- lib/autoconf/general.m4 23 May 2003 13:13:30 -0000 1.816
+++ lib/autoconf/general.m4 21 Aug 2003 17:19:20 -0000
@@ -1875,8 +1875,8 @@
 # AC_DIAGNOSE(CATEGORY, MESSAGE)
 # AC_FATAL(MESSAGE, [EXIT-STATUS])
 # --------------------------------
-m4_copy([m4_warn],  [AC_DIAGNOSE])
-m4_copy([m4_fatal], [AC_FATAL])
+m4_define([AC_DIAGNOSE], [m4_warn($@)])
+m4_define([AC_FATAL],    [m4_fatal($@)])
 
 
 # AC_WARNING(MESSAGE)
Index: lib/m4sugar/m4sugar.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sugar.m4,v
retrieving revision 2.73
diff -u -u -r2.73 m4sugar.m4
--- lib/m4sugar/m4sugar.m4 23 May 2003 13:58:06 -0000 2.73
+++ lib/m4sugar/m4sugar.m4 21 Aug 2003 17:19:21 -0000
@@ -206,70 +206,11 @@
 ## ------------- ##
 
 
-# m4_warning_ifelse(CATEGORY, IF-TRUE, IF-FALSE)
-# ----------------------------------------------
-# If the CATEGORY of warnings is enabled, expand IF_TRUE otherwise
-# IF-FALSE.
-#
-# The variable `m4_warnings' contains a comma separated list of
-# warnings which order is the converse from the one specified by
-# the user, i.e., if she specified `-W error,none,obsolete',
-# `m4_warnings' is `obsolete,none,error'.  We read it from left to
-# right, and:
-# - if none or noCATEGORY is met, run IF-FALSE
-# - if all or CATEGORY is met, run IF-TRUE
-# - if there is nothing left, run IF-FALSE.
-m4_define([m4_warning_ifelse],
-[_m4_warning_ifelse([$1], [$2], [$3], m4_warnings)])
-
-
-# _m4_warning_ifelse(CATEGORY, IF-TRUE, IF-FALSE, WARNING1, ...)
-# --------------------------------------------------------------
-# Implementation of the loop described above.
-m4_define([_m4_warning_ifelse],
-[m4_case([$4],
-        [$1],    [$2],
-        [all],   [$2],
-        [],      [$3],
-        [none],  [$3],
-        [no-$1], [$3],
-        [$0([$1], [$2], [$3], m4_shiftn(4, $@))])])
-
-
-# _m4_warning_error_ifelse(IF-TRUE, IF-FALSE)
-# -------------------------------------------
-# The same as m4_warning_ifelse, but scan for `error' only.
-m4_define([_m4_warning_error_ifelse],
-[__m4_warning_error_ifelse([$1], [$2], m4_warnings)])
-
-
-# __m4_warning_error_ifelse(IF-TRUE, IF-FALSE)
-# --------------------------------------------
-# The same as _m4_warning_ifelse, but scan for `error' only.
-m4_define([__m4_warning_error_ifelse],
-[m4_case([$3],
-        [error],    [$1],
-        [],         [$2],
-        [no-error], [$2],
-        [$0([$1], [$2], m4_shiftn(3, $@))])])
-
-
-
-# _m4_warn(MESSAGE)
-# -----------------
-# Report MESSAGE as a warning, unless the user requested -W error,
-# in which case report a fatal error.
-m4_define([_m4_warn],
-[_m4_warning_error_ifelse([m4_fatal([$1])],
-                         [m4_warning([$1])])])
-
-
 # m4_warn(CATEGORY, MESSAGE)
 # --------------------------
 # Report a MESSAGE to the autoconf user if the CATEGORY of warnings
-# is requested (in fact, not disabled).
-m4_define([m4_warn],
-[m4_warning_ifelse([$1], [_m4_warn([$2])])])
+# is requested (in fact, not disabled).  This is for traces only.
+m4_define([m4_warn], [])
 
 
 
Index: man/autom4te.1
===================================================================
RCS file: /cvsroot/autoconf/autoconf/man/autom4te.1,v
retrieving revision 1.57
diff -u -u -r1.57 autom4te.1
--- man/autom4te.1 20 Aug 2003 07:02:32 -0000 1.57
+++ man/autom4te.1 21 Aug 2003 17:19:21 -0000
@@ -72,23 +72,35 @@
 `cross'
 cross compilation issues
 .TP
+`gnu'
+GNU coding standards (default in gnu and gnits modes)
+.TP
 `obsolete'
-obsolete constructs
+obsolete features or constructions
+.TP
+`override'
+user redefinitions of Automake rules or variables
+.TP
+`portability'
+portability issues
 .TP
 `syntax'
-dubious syntactic constructs
+dubious syntactic constructs (default)
+.TP
+`unsupported'
+unsupported or incomplete features (default)
 .TP
 `all'
 all the warnings
 .TP
 `no-CATEGORY'
-turn off the warnings on CATEGORY
+turn off warnings in CATEGORY
 .TP
 `none'
 turn off all the warnings
 .TP
 `error'
-warnings are error
+treat warnings as errors
 .PP
 The environment variable `WARNINGS' is honored.
 .SS "Library directories:"
Index: tests/m4sugar.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/m4sugar.at,v
retrieving revision 1.22
diff -u -u -r1.22 m4sugar.at
--- tests/m4sugar.at 18 Oct 2002 15:20:46 -0000 1.22
+++ tests/m4sugar.at 21 Aug 2003 17:19:21 -0000
@@ -42,8 +42,8 @@
 # warnings.  But maybe autom4te should handle that by itself?
 
 AT_DATA_M4SUGAR([script.4s],
-[[m4_warn([foo],  [foo])
-m4_warn([bar],    [bar])
+[[m4_warn([obsolete],  [obsolete])
+m4_warn([cross],  [cross])
 m4_warn([syntax], [syntax])
 ]])
 
@@ -52,17 +52,17 @@
 ])
 
 AT_CHECK_M4SUGAR([-o- -Wall -f], 0, [],
-[script.4s:1: warning: foo
-script.4s:2: warning: bar
+[script.4s:1: warning: obsolete
+script.4s:2: warning: cross
 script.4s:3: warning: syntax
 ])
 
-AT_CHECK_M4SUGAR([-o- -Wnone,bar -f], 0, [],
-[script.4s:2: warning: bar
+AT_CHECK_M4SUGAR([-o- -Wnone,cross -f], 0, [],
+[script.4s:2: warning: cross
 ])
 
-AT_CHECK_M4SUGAR([-o- -Wnone,bar,error -f], 1, [],
-[[script.4s:2: error: bar
+AT_CHECK_M4SUGAR([-o- -Wnone,cross,error -f], 1, [],
+[[script.4s:2: error: cross
 script.4s:2: the top level
 autom4te: m4 failed with exit status: 1
 ]])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]