https://gcc.gnu.org/g:6d15251d30baadbfcdda50a5c661ab1aba3465ec

commit r17-1575-g6d15251d30baadbfcdda50a5c661ab1aba3465ec
Author: Jose E. Marchesi <[email protected]>
Date:   Mon Jun 15 16:36:32 2026 +0200

    a68: provide more detail in multiple declaration diagnostics
    
    Signed-off-by: Jose E. Marchesi <[email protected]>
    
    gcc/algol68/ChangeLog
    
            * a68-parser-taxes.cc (attr_descr): New function.
            (already_declared): Use attr_descr for diagnostic.
            (already_declared_hidden): Likewise.

Diff:
---
 gcc/algol68/a68-parser-taxes.cc | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/gcc/algol68/a68-parser-taxes.cc b/gcc/algol68/a68-parser-taxes.cc
index 62418c035ffd..41fe98896e83 100644
--- a/gcc/algol68/a68-parser-taxes.cc
+++ b/gcc/algol68/a68-parser-taxes.cc
@@ -635,13 +635,29 @@ a68_collect_taxes (NODE_T *p)
   test_firmly_related_ops_local (NO_NODE, OPERATORS (A68_STANDENV));
 }
 
+/* Get a description text for attribute passed as the second argument to
+   already_declared and already-declared_hidden.  To be used in
+   diagnostics.  */
+
+static const char *
+attr_descr (int a)
+{
+  return (a == OP_SYMBOL ? "operator"
+         : a == PRIO_SYMBOL ? "priority for operator"
+         : a == INDICANT ? "mode indicant"
+         : a == LABEL ? "label"
+         : a == IDENTIFIER ? "identifier"
+         : "tag");
+}
+
 /* Whether tag has already been declared in this range.  */
 
 static void
 already_declared (NODE_T *n, int a)
 {
   if (find_tag_local (TABLE (n), a, NSYMBOL (n)) != NO_TAG)
-    a68_error (n, "multiple declaration of tag %qs", NSYMBOL (n));
+    a68_error (n, "multiple declaration of %s %qs",
+              attr_descr (a), NSYMBOL (n));
 }
 
 /* Whether tag has already been declared in this range.  */
@@ -650,7 +666,8 @@ static void
 already_declared_hidden (NODE_T *n, int a)
 {
   if (find_tag_local (TABLE (n), a, NSYMBOL (n)) != NO_TAG)
-    a68_error (n, "multiple declaration of tag %qs", NSYMBOL (n));
+    a68_error (n, "multiple declaration of %s %qs",
+              attr_descr (a), NSYMBOL (n));
 
   TAG_T *s = a68_find_tag_global (PREVIOUS (TABLE (n)), a, NSYMBOL (n));
 
@@ -962,7 +979,7 @@ tax_variable_dec (NODE_T *p, int *q, MOID_T **m, bool e)
            HEAP (entry) = STATIC_SYMBOL;
          else
            HEAP (entry) = *q;
-         
+
          if (HEAP (entry) == LOC_SYMBOL)
            {
              TAG_T *z = a68_add_tag (TABLE (p), ANONYMOUS, p, SUB (*m), 
GENERATOR);
@@ -1698,7 +1715,7 @@ a68_mark_auxilliary (NODE_T *p)
 
          if (TAX (p) != NO_TAG)
            USE (TAX (p)) = true;
-         
+
          if ((z = a68_find_tag_global (TABLE (p), PRIO_SYMBOL, NSYMBOL (p))) 
!= NO_TAG)
            USE (z) = true;
        }

Reply via email to