Thanks for the suggestion. Although I didn't go to the trouble of
writing code to generate the multiline diagnostic you suggested, it's
easy to change "possibly undefined macro" (which doesn't cover the
situation you mentioned) to the slightly less confusing "undefined or
overquoted macro". Since the diagnostic can be caused by misspelled
macro names, which do occur, I thought it wise to retain a mention of
that in the diagnostic. I installed the attached patch.From 7a6347d1d785ee26f205154fdadf7f6f81797f92 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 6 Apr 2024 13:01:12 -0700
Subject: [PATCH] =?UTF-8?q?Improve=20=E2=80=9Cpossibly=20undefined=20macro?=
=?UTF-8?q?=E2=80=9D=20diagnostic?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Simplified version of a suggestion by Reuben Thomas in:
https://lists.gnu.org/r/bug-autoconf/2024-04/msg00021.html
* bin/autom4te.in (warn_forbidden): Change message wording.
* tests/tools.at (autom4te and whitespace in file names)
(forbidden tokens, exceptions): Adjust tests to match new behavior.
---
bin/autom4te.in | 4 ++--
tests/tools.at | 24 ++++++++++++------------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/bin/autom4te.in b/bin/autom4te.in
index 2e5209b6..e9fa1886 100644
--- a/bin/autom4te.in
+++ b/bin/autom4te.in
@@ -541,7 +541,7 @@ sub handle_m4 ($@)
# warn_forbidden ($WHERE, $WORD, %FORBIDDEN)
# ------------------------------------------
# $WORD is forbidden. Warn with a dedicated error message if in
-# %FORBIDDEN, otherwise a simple 'error: possibly undefined macro'
+# %FORBIDDEN, otherwise a simple 'error: undefined or overquoted macro'
# will do.
my $first_warn_forbidden = 1;
sub warn_forbidden ($$%)
@@ -557,7 +557,7 @@ sub warn_forbidden ($$%)
last;
}
}
- $message ||= "possibly undefined macro: $word";
+ $message ||= "undefined or overquoted macro: $word";
warn "$where: error: $message\n";
if ($first_warn_forbidden)
{
diff --git a/tests/tools.at b/tests/tools.at
index c42f1ea9..37fe1466 100644
--- a/tests/tools.at
+++ b/tests/tools.at
@@ -192,7 +192,7 @@ END
rm -rf "$outfile" "$cachedir"
AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar -o "$outfile" "$file"],
[1], [], [stderr])
- AT_CHECK([grep 'possibly undefined macro' stderr], [], [ignore])
+ AT_CHECK([grep 'undefined or overquoted macro' stderr], [], [ignore])
cat >"$file" <<'END'
[m4@&t@_init[]m4@&t@_include(foo.m4)
@@ -465,13 +465,13 @@ AT_MTIME_DELAY
AT_CHECK_AUTOCONF([], 1, [],
[[trailer.m4: warning: AC_INIT was never used
trailer.m4: warning: AC_OUTPUT was never used
-configure.ac:2: error: possibly undefined macro: m4@&t@_foo
+configure.ac:2: error: undefined or overquoted macro: m4@&t@_foo
If this token and others are legitimate, please use m4@&t@_pattern_allow.
See the Autoconf documentation.
-configure.ac:3: error: possibly undefined macro: _m4@&t@_bar
-configure.ac:4: error: possibly undefined macro: AS@&t@_FOO
-configure.ac:5: error: possibly undefined macro: _AS@&t@_BAR
-configure.ac:6: error: possibly undefined macro: d@&t@nl
+configure.ac:3: error: undefined or overquoted macro: _m4@&t@_bar
+configure.ac:4: error: undefined or overquoted macro: AS@&t@_FOO
+configure.ac:5: error: undefined or overquoted macro: _AS@&t@_BAR
+configure.ac:6: error: undefined or overquoted macro: d@&t@nl
]])
# On a file system with coarse timestamp resolution (1 or 2s),
@@ -481,7 +481,7 @@ configure.ac:6: error: possibly undefined macro: d@&t@nl
AT_MTIME_DELAY
touch configure
-# Since warnings are replicated from the cache but "possibly undefined
+# Since warnings are replicated from the cache but "undefined or overquoted
# macro" errors are not, a second run, without --force, should succeed
# and should yield only the warnings about AC_INIT and AC_OUTPUT.
AT_CHECK_M4([autoconf], 0, [],
@@ -521,13 +521,13 @@ It would be very bad if Autoconf forgot to expand [AS_]INIT!
AT_CHECK_AUTOCONF([], 1, [],
[[trailer.m4: warning: AC_INIT was never used
trailer.m4: warning: AC_OUTPUT was never used
-configure.ac:1: error: possibly undefined macro: AS@&t@_INIT
+configure.ac:1: error: undefined or overquoted macro: AS@&t@_INIT
If this token and others are legitimate, please use m4@&t@_pattern_allow.
See the Autoconf documentation.
-configure.ac:7: error: possibly undefined macro: AS@&t@_ALLOWED_NOT
-configure.ac:10: error: possibly undefined macro: FORBIDDEN
-configure.ac:14: error: possibly undefined macro: AS@&t@_THIS_IS_INVALID
-configure.ac:14: error: possibly undefined macro: _AS@&t@_THIS_IS_INVALID_TOO
+configure.ac:7: error: undefined or overquoted macro: AS@&t@_ALLOWED_NOT
+configure.ac:10: error: undefined or overquoted macro: FORBIDDEN
+configure.ac:14: error: undefined or overquoted macro: AS@&t@_THIS_IS_INVALID
+configure.ac:14: error: undefined or overquoted macro: _AS@&t@_THIS_IS_INVALID_TOO
]])
AT_CLEANUP
--
2.40.1