* pt.c (tsubst) [TEMPLATE_TYPE_PARM]: Use TEMPLATE_PARM_DESCENDANTS.
authorJason Merrill <jason@redhat.com>
Thu, 21 Jun 2018 18:19:38 +0000 (14:19 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 21 Jun 2018 18:19:38 +0000 (14:19 -0400)
From-SVN: r261861

gcc/cp/ChangeLog
gcc/cp/pt.c

index 18673c095af49dc8c4eb5c0dccfa8d5b041ca731..f0e44532348224482d287c0e7eed75cca1b92b19 100644 (file)
@@ -1,5 +1,7 @@
 2018-06-21  Jason Merrill  <jason@redhat.com>
 
+       * pt.c (tsubst) [TEMPLATE_TYPE_PARM]: Use TEMPLATE_PARM_DESCENDANTS.
+
        * name-lookup.c (do_push_to_top_level): Don't allocate
        current_lang_base.
        (do_pop_from_top_level): Release current_lang_base.
index c5433dc46ae81e39376b2a08480950ebc69ec124..69e9479302eae87fc9c2ee9a2faa3a0ac19f147c 100644 (file)
@@ -14472,6 +14472,15 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
                     && !PLACEHOLDER_TYPE_CONSTRAINTS (r))
              /* Break infinite recursion when substituting the constraints
                 of a constrained placeholder.  */;
+           else if (TREE_CODE (t) == TEMPLATE_TYPE_PARM
+                    && !PLACEHOLDER_TYPE_CONSTRAINTS (t)
+                    && !CLASS_PLACEHOLDER_TEMPLATE (t)
+                    && (arg = TEMPLATE_TYPE_PARM_INDEX (t),
+                        r = TEMPLATE_PARM_DESCENDANTS (arg))
+                    && (TEMPLATE_PARM_LEVEL (r)
+                        == TEMPLATE_PARM_LEVEL (arg) - levels))
+               /* Cache the simple case of lowering a type parameter.  */
+             r = TREE_TYPE (r);
            else
              {
                r = copy_type (t);