https://gcc.gnu.org/g:9b8caae8d189c5bd7de502844b17341a7a6dddc5

commit r16-870-g9b8caae8d189c5bd7de502844b17341a7a6dddc5
Author: Jason Merrill <ja...@redhat.com>
Date:   Thu May 22 17:11:50 2025 -0400

    c++: dump_template_bindings tweak
    
    in r12-1100 we stopped printing template bindings like T = T.  The check for
    this relied on TREE_CHAIN of a TEMPLATE_TYPE_PARM holding the declaration of
    that type-parameter.  This should be written as TYPE_STUB_DECL.  In
    addition, TYPE_STUB_DECL is only set on the TYPE_MAIN_VARIANT, so we need to
    check that as well.  Which is also desirable because volatile T is visibly
    distinct from T.
    
    gcc/cp/ChangeLog:
    
            * error.cc (dump_template_bindings): Correct skipping of
            redundant bindings.

Diff:
---
 gcc/cp/error.cc | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index 75bf7dcef62d..305064d476c4 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -541,12 +541,13 @@ dump_template_bindings (cxx_pretty_printer *pp, tree 
parms, tree args,
          /* If the template argument repeats the template parameter (T = T),
             skip the parameter.*/
          if (arg && TREE_CODE (arg) == TEMPLATE_TYPE_PARM
-               && TREE_CODE (parm_i) == TREE_LIST
-               && TREE_CODE (TREE_VALUE (parm_i)) == TYPE_DECL
-               && TREE_CODE (TREE_TYPE (TREE_VALUE (parm_i)))
-                    == TEMPLATE_TYPE_PARM
-               && DECL_NAME (TREE_VALUE (parm_i))
-                    == DECL_NAME (TREE_CHAIN (arg)))
+             && arg == TYPE_MAIN_VARIANT (arg)
+             && TREE_CODE (parm_i) == TREE_LIST
+             && TREE_CODE (TREE_VALUE (parm_i)) == TYPE_DECL
+             && (TREE_CODE (TREE_TYPE (TREE_VALUE (parm_i)))
+                 == TEMPLATE_TYPE_PARM)
+             && (DECL_NAME (TREE_VALUE (parm_i))
+                 == DECL_NAME (TYPE_STUB_DECL (arg))))
            continue;
 
          semicolon_or_introducer ();

Reply via email to