[gcc r16-9347] a68: provide more detail in multiple declaration diagnostics

"Jose E. Marchesi via Gcc-cvs" <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:5e8784e60877e1b6d42985c15fe7ae00f17aed18

commit r16-9347-g5e8784e60877e1b6d42985c15fe7ae00f17aed18
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.
    
    (cherry picked from commit 6d15251d30baadbfcdda50a5c661ab1aba3465ec)

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;
 	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.