]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: dump_template_bindings tweak
authorJason Merrill <jason@redhat.com>
Thu, 22 May 2025 21:11:50 +0000 (17:11 -0400)
committerJason Merrill <jason@redhat.com>
Sun, 25 May 2025 14:30:00 +0000 (10:30 -0400)
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

index 75bf7dcef62d3cfa2043784c2cb30d48d0e36560..305064d476c45732fcd397dfab256be253afe7bd 100644 (file)
@@ -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 ();