https://gcc.gnu.org/g:d608177035964c1255873c5b544b5d4f690184b5

commit r17-1434-gd608177035964c1255873c5b544b5d4f690184b5
Author: Jose E. Marchesi <[email protected]>
Date:   Tue Jun 9 01:09:22 2026 +0200

    a68: fix diagnostic strings in a68_attr_format_token
    
    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 <[email protected]>
    
    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.

Diff:
---
 gcc/algol68/a68-pretty-print.h                              | 8 +++-----
 gcc/testsuite/algol68/compile/error-attr-format-token-1.a68 | 5 +++++
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/algol68/a68-pretty-print.h b/gcc/algol68/a68-pretty-print.h
index ef74c43089ff..16dbb415b861 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 000000000000..b6f139368dd9
--- /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

Reply via email to