diff mbox

[C++] {NON,}TYPE_ARGUMENT_PACK substitution

Message ID 99827597-6b58-e427-ef6c-69e63228011b@acm.org
State New
Headers show

Commit Message

Nathan Sidwell Dec. 7, 2016, 1:01 p.m. UTC
I also noticed argument pack substitution was doing more work than 
necessary -- we've already tsubst'd TYPE just before the big switch. 
Took the opportunity to simplify the control flow a bit further too.

Committed.

nathan
-- 
Nathan Sidwell
diff mbox

Patch

2016-12-07  Nathan Sidwell  <nathan@acm.org>

	* pt.c (tsubst <{NON,}TYPE_ARGUMENT_PACK>: Simplify control flow
	and avoid re-tsubsting type.

Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 243342)
+++ cp/pt.c	(working copy)
@@ -13795,22 +13795,23 @@  tsubst (tree t, tree args, tsubst_flags_
     case TYPE_ARGUMENT_PACK:
     case NONTYPE_ARGUMENT_PACK:
       {
-        tree r = TYPE_P (t) ? cxx_make_type (code) : make_node (code);
-        tree packed_out = 
-          tsubst_template_args (ARGUMENT_PACK_ARGS (t), 
-                                args,
-                                complain,
-                                in_decl);
-        SET_ARGUMENT_PACK_ARGS (r, packed_out);
+        tree r;
 
-        /* For template nontype argument packs, also substitute into
-           the type.  */
-        if (code == NONTYPE_ARGUMENT_PACK)
-          TREE_TYPE (r) = tsubst (TREE_TYPE (t), args, complain, in_decl);
+	if (code == NONTYPE_ARGUMENT_PACK)
+	  {
+	    r = make_node (code);
+	    /* Set the already-substituted type.  */
+	    TREE_TYPE (r) = type;
+	  }
+	else
+	  r = cxx_make_type (code);
 
-        return r;
+	tree pack_args = ARGUMENT_PACK_ARGS (t);
+	pack_args = tsubst_template_args (pack_args, args, complain, in_decl);
+	SET_ARGUMENT_PACK_ARGS (r, pack_args);
+
+	return r;
       }
-      break;
 
     case VOID_CST:
     case INTEGER_CST: