aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-10-03 00:32:35 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-10-03 00:32:35 -0400
commit874fc1677e7a922228632a9235613fa2814606bf (patch)
treeb32e7d7fcc786cf4683f9c31194ddf6289270565 /gcc
parenta558c1e2e1e87fd562909a5170b5722df2681b2a (diff)
downloadgcc-874fc1677e7a922228632a9235613fa2814606bf.zip
gcc-874fc1677e7a922228632a9235613fa2814606bf.tar.gz
gcc-874fc1677e7a922228632a9235613fa2814606bf.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/pt.c49
2 files changed, 31 insertions, 21 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c349549..c8ca7c5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
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 {}
in a template.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 015ee37..051c89a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9102,7 +9102,8 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
tree in_decl)
{
tree pattern;
- tree pack, packs = NULL_TREE, unsubstituted_packs = NULL_TREE;
+ tree pack, packs = NULL_TREE;
+ bool unsubstituted_packs = false;
int i, len = -1;
tree result;
htab_t saved_local_specializations = NULL;
@@ -9203,10 +9204,11 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
TREE_TYPE (packs) = orig_arg;
}
else
- /* We can't substitute for this parameter pack. */
- unsubstituted_packs = tree_cons (TREE_PURPOSE (pack),
- TREE_VALUE (pack),
- unsubstituted_packs);
+ {
+ /* We can't substitute for this parameter pack. */
+ unsubstituted_packs = true;
+ break;
+ }
}
/* 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,
for (pack = packs; pack; pack = TREE_CHAIN (pack))
{
tree parm = TREE_PURPOSE (pack);
+ tree arg;
+ /* Select the Ith argument from the pack. */
if (TREE_CODE (parm) == PARM_DECL)
{
- /* Select the Ith argument from the pack. */
- tree arg = make_node (ARGUMENT_PACK_SELECT);
- ARGUMENT_PACK_SELECT_FROM_PACK (arg) = TREE_VALUE (pack);
- ARGUMENT_PACK_SELECT_INDEX (arg) = i;
- mark_used (parm);
- register_local_specialization (arg, parm);
+ if (i == 0)
+ {
+ arg = make_node (ARGUMENT_PACK_SELECT);
+ ARGUMENT_PACK_SELECT_FROM_PACK (arg) = TREE_VALUE (pack);
+ mark_used (parm);
+ register_local_specialization (arg, parm);
+ }
+ else
+ arg = retrieve_local_specialization (parm);
}
else
{
- tree value = parm;
int idx, level;
template_parm_level_and_index (parm, &level, &idx);
-
- if (i < len)
+
+ if (i == 0)
{
- /* Select the Ith argument from the pack. */
- value = make_node (ARGUMENT_PACK_SELECT);
- ARGUMENT_PACK_SELECT_FROM_PACK (value) = TREE_VALUE (pack);
- ARGUMENT_PACK_SELECT_INDEX (value) = i;
+ arg = make_node (ARGUMENT_PACK_SELECT);
+ ARGUMENT_PACK_SELECT_FROM_PACK (arg) = TREE_VALUE (pack);
+ /* Update the corresponding argument. */
+ TMPL_ARG (args, level, idx) = arg;
}
-
- /* Update the corresponding argument. */
- TMPL_ARG (args, level, idx) = value;
+ else
+ /* Re-use the ARGUMENT_PACK_SELECT. */
+ arg = TMPL_ARG (args, level, idx);
}
+ ARGUMENT_PACK_SELECT_INDEX (arg) = i;
}
/* Substitute into the PATTERN with the altered arguments. */