aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/pt.c
diff options
context:
space:
mode:
authorDouglas Gregor <doug.gregor@gmail.com>2008-03-27 14:31:47 +0000
committerDoug Gregor <dgregor@gcc.gnu.org>2008-03-27 14:31:47 +0000
commit063cc99c4658d52b33b37f4173d304efa9c68b00 (patch)
tree85efa960309333d8820defc88b6374fdcae35ac4 /gcc/cp/pt.c
parentc91c9c2ee8a877a31e6a4ecf93b3fe0d779afcc0 (diff)
downloadgcc-063cc99c4658d52b33b37f4173d304efa9c68b00.zip
gcc-063cc99c4658d52b33b37f4173d304efa9c68b00.tar.gz
gcc-063cc99c4658d52b33b37f4173d304efa9c68b00.tar.bz2
pt.c (tsubst_copy): Cope with tsubst_pack_expansion returning a pack expansion...
2008-03-27 Douglas Gregor <doug.gregor@gmail.com> * pt.c (tsubst_copy) <case SIZEOF_EXPR>: Cope with tsubst_pack_expansion returning a pack expansion, or a TREE_VEC ending in a pack expansion, both of which can occur when substituting into a nested template. (tsubst_copy_and_build) <case SIZEOF_EXPR>: When we're instantiating the sizeof...(X) form, make tsubst_copy do the work. * parser.c (cp_parser_template_parameter): Deal with unnamed non-type template parameter packs identified by pack expansions in the parameter type. 2008-03-27 Douglas Gregor <doug.gregor@gmail.com> * g++.dg/cpp0x/variadic91.C: New. From-SVN: r133642
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r--gcc/cp/pt.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 6f7efa6..6954a1b 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9916,9 +9916,30 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
/* We only want to compute the number of arguments. */
tree expanded = tsubst_pack_expansion (TREE_OPERAND (t, 0), args,
complain, in_decl);
+ int len;
+
+ if (TREE_CODE (expanded) == TREE_VEC)
+ len = TREE_VEC_LENGTH (expanded);
+
if (expanded == error_mark_node)
return error_mark_node;
- return build_int_cst (size_type_node, TREE_VEC_LENGTH (expanded));
+ else if (PACK_EXPANSION_P (expanded)
+ || (TREE_CODE (expanded) == TREE_VEC
+ && len > 0
+ && PACK_EXPANSION_P (TREE_VEC_ELT (expanded, len-1))))
+ {
+ if (TREE_CODE (expanded) == TREE_VEC)
+ expanded = TREE_VEC_ELT (expanded, len - 1);
+
+ if (TYPE_P (expanded))
+ return cxx_sizeof_or_alignof_type (expanded, SIZEOF_EXPR,
+ complain & tf_error);
+ else
+ return cxx_sizeof_or_alignof_expr (expanded, SIZEOF_EXPR,
+ complain & tf_error);
+ }
+ else
+ return build_int_cst (size_type_node, len);
}
/* Fall through */
@@ -10918,14 +10939,7 @@ tsubst_copy_and_build (tree t,
case SIZEOF_EXPR:
if (PACK_EXPANSION_P (TREE_OPERAND (t, 0)))
- {
- /* We only want to compute the number of arguments. */
- tree expanded = tsubst_pack_expansion (TREE_OPERAND (t, 0), args,
- complain, in_decl);
- if (expanded == error_mark_node)
- return error_mark_node;
- return build_int_cst (size_type_node, TREE_VEC_LENGTH (expanded));
- }
+ return tsubst_copy (t, args, complain, in_decl);
/* Fall through */
case ALIGNOF_EXPR:
@@ -12920,7 +12934,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict)
tree parmvec = TYPE_TI_ARGS (parm);
tree argvec = INNERMOST_TEMPLATE_ARGS (TYPE_TI_ARGS (arg));
tree parm_parms
- = DECL_INNERMOST_TEMPLATE_PARMS
+ = DECL_INNERMOST_TEMPLATE_PARMS
(TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL (parm));
int i, len;
int parm_variadic_p = 0;