[COMMITTED] a68: fix diagnostic strings in a68_attr_format_token
Jose E. Marchesi
jemarch@gnu.org
Mon Jun 8 23:13:01 GMT 2026
The a68_attr_format_token class is incorrectly using
a68_find_keyword_from_attribute to get the diagnostic message, rather
than the intended descriptive text for the attribute.
This patch fixes this and adds a little testcase.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
* a68-pretty-print.h (a68_attr_format_token): Get diagnostic
string from a68_attribute_name.
gcc/testsuite/ChangeLog
* algol68/compile/error-attr-format-token-1.a68: New test.
---
gcc/algol68/a68-pretty-print.h | 8 +++-----
.../algol68/compile/error-attr-format-token-1.a68 | 5 +++++
2 files changed, 8 insertions(+), 5 deletions(-)
create mode 100644 gcc/testsuite/algol68/compile/error-attr-format-token-1.a68
diff --git a/gcc/algol68/a68-pretty-print.h b/gcc/algol68/a68-pretty-print.h
index ef74c43089f..16dbb415b86 100644
--- a/gcc/algol68/a68-pretty-print.h
+++ b/gcc/algol68/a68-pretty-print.h
@@ -129,11 +129,9 @@ struct a68_attr_format_token : public a68_format_token
public:
a68_attr_format_token (enum a68_attribute a)
{
- KEYWORD_T *nt = a68_find_keyword_from_attribute (A68 (top_keyword), a);
- if (nt != NO_KEYWORD)
- m_str = xstrdup (a68_strop_keyword (TEXT (nt)));
- else
- m_str = xstrdup ("keyword");
+ const char *attr_name = a68_attribute_name (a);
+ gcc_assert (attr_name != NULL);
+ m_str = xstrdup (attr_name);
}
};
diff --git a/gcc/testsuite/algol68/compile/error-attr-format-token-1.a68 b/gcc/testsuite/algol68/compile/error-attr-format-token-1.a68
new file mode 100644
index 00000000000..b6f139368dd
--- /dev/null
+++ b/gcc/testsuite/algol68/compile/error-attr-format-token-1.a68
@@ -0,0 +1,5 @@
+begin mode Set = struct (string class, ref[]int elems);
+ Set empty_set
+ = ("", heap[1:0]Elems); { dg-error "collateral clause" }
+ skip
+end
--
2.39.5
More information about the Algol68
mailing list