Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

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.
---
 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 75bf7dcef62..305064d476c 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 ();

base-commit: e3d3d6d7d2c8ab73ff597f4c82514c3217256567
-- 
2.49.0

Reply via email to