]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Output stack traces in warnings.
authorAkim Demaille <akim@epita.fr>
Fri, 22 Aug 2003 13:38:33 +0000 (13:38 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 22 Aug 2003 13:38:33 +0000 (13:38 +0000)
* lib/m4sugar/m4sugar.m4 (_m4_warn): New.
Replace the former...
(m4_warn): Pass the call stack to _m4_warn.
* bin/autom4te.in: Adjust to output the call stack.
* tests/m4sugar.at (m4@&t@_warn): Adjust.

ChangeLog
bin/autom4te.in
lib/m4sugar/m4sugar.m4
tests/m4sugar.at

index 1ed03087d18782e207a4dcf168d2e7051ec21194..f4df52fb44fc274f7d0366d64487e703dfeded64 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2003-08-22  Akim Demaille  <akim@epita.fr>
+
+       Output stack traces in warnings.
+
+       * lib/m4sugar/m4sugar.m4 (_m4_warn): New.
+       Replace the former...
+       (m4_warn): Pass the call stack to _m4_warn.
+       * bin/autom4te.in: Adjust to output the call stack.
+       * tests/m4sugar.at (m4@&t@_warn): Adjust.
+
 2003-08-22  Akim Demaille  <akim@epita.fr>
 
        * lib/Autom4te/Request.pm, lib/Autom4te/C4che.pm: New.
index 6a7bc80d734e951fe8061f66ad785695d702b371..1a20d5a25e32db9e7ee6344fac6cc5a09c4c45e6 100644 (file)
@@ -78,7 +78,7 @@ my %trace;
 # FIXME: What about `sinclude'?
 my @preselect = ('include',
                 'm4_pattern_allow', 'm4_pattern_forbid',
-                'm4_warn');
+                '_m4_warn');
 
 # M4 include path.
 my @include;
@@ -993,11 +993,23 @@ handle_m4 ($req, keys %{$req->macro})
 
 # Issue the warnings each time autom4te was run.
 handle_traces ($req, "$tmp/warnings",
-              ('m4_warn' => "\$1::\$f:\$l::\$2\n\n"));
+              ('_m4_warn' => "\$1::\$f:\$l::\$2::\$3\n\n"));
+# Warnings are separated by 2 \n.
 for (split (/\n{2,}/, contents ("$tmp/warnings")))
 {
-  my ($cat, $loc, $msg) = split '::';
+  # The message looks like:
+  # | syntax::input.as:5::ouch
+  # | ::input.as:4: baz is expanded from...
+  # | input.as:2: bar is expanded from...
+  # | input.as:3: foo is expanded from...
+  # | input.as:5: the top level
+  my ($cat, $loc, $msg, $stacktrace) = split ('::', $_, 4);
   msg $cat, $loc, "warning: $msg";
+  for (split /\n/, $stacktrace)
+    {
+      my ($loc, $trace) = split (': ', $_, 2);
+      msg $cat, $loc, $trace;
+    }
 }
 
 # Now output...
index 2fd34960b6b33056f2d4aaa3fd8b97687aff6427..42210125b7ed3b907c1a051b5a6d5bee4cb3c68a 100644 (file)
@@ -201,17 +201,29 @@ m4_define([m4_assert],
        [m4_fatal([assert failed: $1], [$2])])])
 
 
+
 ## ------------- ##
 ## 3. Warnings.  ##
 ## ------------- ##
 
 
+# _m4_warn(CATEGORY, MESSAGE, STACK-TRACE)
+# ----------------------------------------
+# Report a MESSAGE to the user if the CATEGORY of warnings is enabled.
+# This is for traces only.
+# The STACK-TRACE is a \n-separated list of "LOCATION: MESSAGE".
+m4_define([_m4_warn], [])
+
+
 # m4_warn(CATEGORY, MESSAGE)
 # --------------------------
-# Report a MESSAGE to the autoconf user if the CATEGORY of warnings
-# is requested (in fact, not disabled).  This is for traces only.
-m4_define([m4_warn], [])
-
+# Report a MESSAGE to the user if the CATEGORY of warnings is enabled.
+m4_define([m4_warn],
+[_m4_warn([$1], [$2],
+m4_ifdef([m4_expansion_stack],
+         [m4_defn([m4_expansion_stack])
+m4_location[: the top level]]))
+])
 
 
 
index 99a4c30080279013f96738f2d6f3f7b19b29c263..716d8df86b3264575a38ca08e2b9870718f56cd9 100644 (file)
@@ -42,29 +42,38 @@ AT_SETUP([[m4@&t@_warn]])
 # warnings.  But maybe autom4te should handle that by itself?
 
 AT_DATA_M4SUGAR([script.4s],
-[[m4_warn([obsolete],  [obsolete])
-m4_warn([cross],  [cross])
+[[m4_init
+m4_defun([cross_warning],
+[m4_warn([cross],  [cross])
+])
+
+m4_warn([obsolete],  [obsolete])
+cross_warning
 m4_warn([syntax], [syntax])
 ]])
 
 AT_CHECK_M4SUGAR([-o-], 0, [],
-[script.4s:3: warning: syntax
+[script.4s:8: warning: syntax
 ])
 
 AT_CHECK_M4SUGAR([-o- -Wall -f], 0, [],
-[script.4s:1: warning: obsolete
-script.4s:2: warning: cross
-script.4s:3: warning: syntax
+[script.4s:6: warning: obsolete
+script.4s:7: warning: cross
+script.4s:4: cross_warning is expanded from...
+script.4s:7: the top level
+script.4s:8: warning: syntax
 ])
 
 AT_CHECK_M4SUGAR([-o- -Wnone,cross -f], 0, [],
-[script.4s:2: warning: cross
+[script.4s:7: warning: cross
+script.4s:4: cross_warning is expanded from...
+script.4s:7: the top level
 ])
 
 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
+[[script.4s:7: warning: cross
+script.4s:4: cross_warning is expanded from...
+script.4s:7: the top level
 ]])
 
 AT_CLEANUP