Commit 73f4e2d2 by Jason Merrill Committed by Jason Merrill

re PR c++/41933 ([c++0x] lambdas and variadic templates don't work together)

	PR c++/41933
	* cp-tree.h (DECL_PACK_P): Replace FUNCTION_PARAMETER_PACK_P.
	* cxx-pretty-print.c (direct_declarator): Adjust.
	* decl2.c (cp_build_parm_decl): Adjust.
	* pt.c (function_parameter_pack_p): Adjust.
	(find_parameter_packs_r, push_template_decl_real): Adjust.
	(tsubst_pack_expansion, tsubst_decl): Adjust.
	(regenerate_decl_from_template, instantiate_decl): Adjust.

From-SVN: r202604
parent 018795f4
2013-09-15 Jason Merrill <jason@redhat.com> 2013-09-15 Jason Merrill <jason@redhat.com>
PR c++/41933
* cp-tree.h (DECL_PACK_P): Replace FUNCTION_PARAMETER_PACK_P.
* cxx-pretty-print.c (direct_declarator): Adjust.
* decl2.c (cp_build_parm_decl): Adjust.
* pt.c (function_parameter_pack_p): Adjust.
(find_parameter_packs_r, push_template_decl_real): Adjust.
(tsubst_pack_expansion, tsubst_decl): Adjust.
(regenerate_decl_from_template, instantiate_decl): Adjust.
* lambda.c (add_capture): Don't add DECL_LANG_SPECIFIC. * lambda.c (add_capture): Don't add DECL_LANG_SPECIFIC.
2013-09-13 Jason Merrill <jason@redhat.com> 2013-09-13 Jason Merrill <jason@redhat.com>
......
...@@ -138,7 +138,6 @@ c-common.h, not after. ...@@ -138,7 +138,6 @@ c-common.h, not after.
1: C_TYPEDEF_EXPLICITLY_SIGNED (in TYPE_DECL). 1: C_TYPEDEF_EXPLICITLY_SIGNED (in TYPE_DECL).
DECL_TEMPLATE_INSTANTIATED (in a VAR_DECL or a FUNCTION_DECL) DECL_TEMPLATE_INSTANTIATED (in a VAR_DECL or a FUNCTION_DECL)
DECL_MEMBER_TEMPLATE_P (in TEMPLATE_DECL) DECL_MEMBER_TEMPLATE_P (in TEMPLATE_DECL)
FUNCTION_PARAMETER_PACK_P (in PARM_DECL)
USING_DECL_TYPENAME_P (in USING_DECL) USING_DECL_TYPENAME_P (in USING_DECL)
DECL_VLA_CAPTURE_P (in FIELD_DECL) DECL_VLA_CAPTURE_P (in FIELD_DECL)
2: DECL_THIS_EXTERN (in VAR_DECL or FUNCTION_DECL). 2: DECL_THIS_EXTERN (in VAR_DECL or FUNCTION_DECL).
...@@ -2874,10 +2873,9 @@ extern void decl_shadowed_for_var_insert (tree, tree); ...@@ -2874,10 +2873,9 @@ extern void decl_shadowed_for_var_insert (tree, tree);
the class definition is complete. */ the class definition is complete. */
#define TEMPLATE_PARMS_FOR_INLINE(NODE) TREE_LANG_FLAG_1 (NODE) #define TEMPLATE_PARMS_FOR_INLINE(NODE) TREE_LANG_FLAG_1 (NODE)
/* Determine if a parameter (i.e., a PARM_DECL) is a function /* Determine if a declaration (PARM_DECL or FIELD_DECL) is a pack. */
parameter pack. */ #define DECL_PACK_P(NODE) \
#define FUNCTION_PARAMETER_PACK_P(NODE) \ (DECL_P (NODE) && PACK_EXPANSION_P (TREE_TYPE (NODE)))
(DECL_LANG_FLAG_1 (PARM_DECL_CHECK (NODE)))
/* Determines if NODE is an expansion of one or more parameter packs, /* Determines if NODE is an expansion of one or more parameter packs,
e.g., a TYPE_PACK_EXPANSION or EXPR_PACK_EXPANSION. */ e.g., a TYPE_PACK_EXPANSION or EXPR_PACK_EXPANSION. */
......
...@@ -1527,7 +1527,7 @@ cxx_pretty_printer::direct_declarator (tree t) ...@@ -1527,7 +1527,7 @@ cxx_pretty_printer::direct_declarator (tree t)
{ {
pp_cxx_space_for_pointer_operator (this, TREE_TYPE (t)); pp_cxx_space_for_pointer_operator (this, TREE_TYPE (t));
if ((TREE_CODE (t) == PARM_DECL && FUNCTION_PARAMETER_PACK_P (t)) if ((TREE_CODE (t) == PARM_DECL && DECL_PACK_P (t))
|| template_parameter_pack_p (t)) || template_parameter_pack_p (t))
/* A function parameter pack or non-type template /* A function parameter pack or non-type template
parameter pack. */ parameter pack. */
......
...@@ -188,11 +188,6 @@ cp_build_parm_decl (tree name, tree type) ...@@ -188,11 +188,6 @@ cp_build_parm_decl (tree name, tree type)
if (!processing_template_decl) if (!processing_template_decl)
DECL_ARG_TYPE (parm) = type_passed_as (type); DECL_ARG_TYPE (parm) = type_passed_as (type);
/* If the type is a pack expansion, then we have a function
parameter pack. */
if (type && TREE_CODE (type) == TYPE_PACK_EXPANSION)
FUNCTION_PARAMETER_PACK_P (parm) = 1;
return parm; return parm;
} }
......
...@@ -2852,7 +2852,7 @@ bool ...@@ -2852,7 +2852,7 @@ bool
function_parameter_pack_p (const_tree t) function_parameter_pack_p (const_tree t)
{ {
if (t && TREE_CODE (t) == PARM_DECL) if (t && TREE_CODE (t) == PARM_DECL)
return FUNCTION_PARAMETER_PACK_P (t); return DECL_PACK_P (t);
return false; return false;
} }
...@@ -3085,7 +3085,7 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data) ...@@ -3085,7 +3085,7 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
break; break;
case PARM_DECL: case PARM_DECL:
if (FUNCTION_PARAMETER_PACK_P (t)) if (DECL_PACK_P (t))
{ {
/* We don't want to walk into the type of a PARM_DECL, /* We don't want to walk into the type of a PARM_DECL,
because we don't want to see the type parameter pack. */ because we don't want to see the type parameter pack. */
...@@ -4646,7 +4646,7 @@ push_template_decl_real (tree decl, bool is_friend) ...@@ -4646,7 +4646,7 @@ push_template_decl_real (tree decl, bool is_friend)
while (arg && argtype) while (arg && argtype)
{ {
if (!FUNCTION_PARAMETER_PACK_P (arg) if (!DECL_PACK_P (arg)
&& check_for_bare_parameter_packs (TREE_TYPE (arg))) && check_for_bare_parameter_packs (TREE_TYPE (arg)))
{ {
/* This is a PARM_DECL that contains unexpanded parameter /* This is a PARM_DECL that contains unexpanded parameter
...@@ -9472,7 +9472,7 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, ...@@ -9472,7 +9472,7 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain,
have the wrong value for a recursive call. Just make a have the wrong value for a recursive call. Just make a
dummy decl, since it's only used for its type. */ dummy decl, since it's only used for its type. */
arg_pack = tsubst_decl (parm_pack, args, complain); arg_pack = tsubst_decl (parm_pack, args, complain);
if (arg_pack && FUNCTION_PARAMETER_PACK_P (arg_pack)) if (arg_pack && DECL_PACK_P (arg_pack))
/* Partial instantiation of the parm_pack, we can't build /* Partial instantiation of the parm_pack, we can't build
up an argument pack yet. */ up an argument pack yet. */
arg_pack = NULL_TREE; arg_pack = NULL_TREE;
...@@ -10465,7 +10465,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) ...@@ -10465,7 +10465,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
tree prev_r = NULL_TREE; tree prev_r = NULL_TREE;
tree first_r = NULL_TREE; tree first_r = NULL_TREE;
if (FUNCTION_PARAMETER_PACK_P (t)) if (DECL_PACK_P (t))
{ {
/* If there is a local specialization that isn't a /* If there is a local specialization that isn't a
parameter pack, it means that we're doing a "simple" parameter pack, it means that we're doing a "simple"
...@@ -10515,10 +10515,6 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) ...@@ -10515,10 +10515,6 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
/* We're on the Ith parameter of the function parameter /* We're on the Ith parameter of the function parameter
pack. */ pack. */
{ {
/* An argument of a function parameter pack is not a parameter
pack. */
FUNCTION_PARAMETER_PACK_P (r) = false;
/* Get the Ith type. */ /* Get the Ith type. */
type = TREE_VEC_ELT (expanded_types, i); type = TREE_VEC_ELT (expanded_types, i);
...@@ -18705,7 +18701,7 @@ regenerate_decl_from_template (tree decl, tree tmpl) ...@@ -18705,7 +18701,7 @@ regenerate_decl_from_template (tree decl, tree tmpl)
pattern_parm pattern_parm
= skip_artificial_parms_for (code_pattern, = skip_artificial_parms_for (code_pattern,
DECL_ARGUMENTS (code_pattern)); DECL_ARGUMENTS (code_pattern));
while (decl_parm && !FUNCTION_PARAMETER_PACK_P (pattern_parm)) while (decl_parm && !DECL_PACK_P (pattern_parm))
{ {
tree parm_type; tree parm_type;
tree attributes; tree attributes;
...@@ -18728,7 +18724,7 @@ regenerate_decl_from_template (tree decl, tree tmpl) ...@@ -18728,7 +18724,7 @@ regenerate_decl_from_template (tree decl, tree tmpl)
} }
/* Merge any parameters that match with the function parameter /* Merge any parameters that match with the function parameter
pack. */ pack. */
if (pattern_parm && FUNCTION_PARAMETER_PACK_P (pattern_parm)) if (pattern_parm && DECL_PACK_P (pattern_parm))
{ {
int i, len; int i, len;
tree expanded_types; tree expanded_types;
...@@ -19247,7 +19243,7 @@ instantiate_decl (tree d, int defer_ok, ...@@ -19247,7 +19243,7 @@ instantiate_decl (tree d, int defer_ok,
} }
for (; tmpl_parm; tmpl_parm = DECL_CHAIN (tmpl_parm)) for (; tmpl_parm; tmpl_parm = DECL_CHAIN (tmpl_parm))
{ {
if (!FUNCTION_PARAMETER_PACK_P (tmpl_parm)) if (!DECL_PACK_P (tmpl_parm))
{ {
register_local_specialization (spec_parm, tmpl_parm); register_local_specialization (spec_parm, tmpl_parm);
spec_parm = DECL_CHAIN (spec_parm); spec_parm = DECL_CHAIN (spec_parm);
......
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