Commit 874fc167 by Jason Merrill Committed by Jason Merrill

pt.c (tsubst_pack_expansion): Re-use ARGUMENT_PACK_SELECTs.

	* pt.c (tsubst_pack_expansion): Re-use ARGUMENT_PACK_SELECTs.
	Change unsubstituted_packs to bool.

From-SVN: r179444
parent a558c1e2
2011-10-02 Jason Merrill <jason@redhat.com> 2011-10-02 Jason Merrill <jason@redhat.com>
* pt.c (tsubst_pack_expansion): Re-use ARGUMENT_PACK_SELECTs.
Change unsubstituted_packs to bool.
* parser.c (cp_parser_range_for): Don't try to deduce from {} * parser.c (cp_parser_range_for): Don't try to deduce from {}
in a template. in a template.
......
...@@ -9102,7 +9102,8 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, ...@@ -9102,7 +9102,8 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
tree in_decl) tree in_decl)
{ {
tree pattern; tree pattern;
tree pack, packs = NULL_TREE, unsubstituted_packs = NULL_TREE; tree pack, packs = NULL_TREE;
bool unsubstituted_packs = false;
int i, len = -1; int i, len = -1;
tree result; tree result;
htab_t saved_local_specializations = NULL; htab_t saved_local_specializations = NULL;
...@@ -9203,10 +9204,11 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, ...@@ -9203,10 +9204,11 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
TREE_TYPE (packs) = orig_arg; TREE_TYPE (packs) = orig_arg;
} }
else else
/* We can't substitute for this parameter pack. */ {
unsubstituted_packs = tree_cons (TREE_PURPOSE (pack), /* We can't substitute for this parameter pack. */
TREE_VALUE (pack), unsubstituted_packs = true;
unsubstituted_packs); break;
}
} }
/* We cannot expand this expansion expression, because we don't have /* We cannot expand this expansion expression, because we don't have
...@@ -9252,33 +9254,38 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, ...@@ -9252,33 +9254,38 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
for (pack = packs; pack; pack = TREE_CHAIN (pack)) for (pack = packs; pack; pack = TREE_CHAIN (pack))
{ {
tree parm = TREE_PURPOSE (pack); tree parm = TREE_PURPOSE (pack);
tree arg;
/* Select the Ith argument from the pack. */
if (TREE_CODE (parm) == PARM_DECL) if (TREE_CODE (parm) == PARM_DECL)
{ {
/* Select the Ith argument from the pack. */ if (i == 0)
tree arg = make_node (ARGUMENT_PACK_SELECT); {
ARGUMENT_PACK_SELECT_FROM_PACK (arg) = TREE_VALUE (pack); arg = make_node (ARGUMENT_PACK_SELECT);
ARGUMENT_PACK_SELECT_INDEX (arg) = i; ARGUMENT_PACK_SELECT_FROM_PACK (arg) = TREE_VALUE (pack);
mark_used (parm); mark_used (parm);
register_local_specialization (arg, parm); register_local_specialization (arg, parm);
}
else
arg = retrieve_local_specialization (parm);
} }
else else
{ {
tree value = parm;
int idx, level; int idx, level;
template_parm_level_and_index (parm, &level, &idx); template_parm_level_and_index (parm, &level, &idx);
if (i < len) if (i == 0)
{ {
/* Select the Ith argument from the pack. */ arg = make_node (ARGUMENT_PACK_SELECT);
value = make_node (ARGUMENT_PACK_SELECT); ARGUMENT_PACK_SELECT_FROM_PACK (arg) = TREE_VALUE (pack);
ARGUMENT_PACK_SELECT_FROM_PACK (value) = TREE_VALUE (pack); /* Update the corresponding argument. */
ARGUMENT_PACK_SELECT_INDEX (value) = i; TMPL_ARG (args, level, idx) = arg;
} }
else
/* Update the corresponding argument. */ /* Re-use the ARGUMENT_PACK_SELECT. */
TMPL_ARG (args, level, idx) = value; arg = TMPL_ARG (args, level, idx);
} }
ARGUMENT_PACK_SELECT_INDEX (arg) = i;
} }
/* Substitute into the PATTERN with the altered arguments. */ /* Substitute into the PATTERN with the altered arguments. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment