summaryrefslogtreecommitdiff
path: root/gcc/cp/lambda.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-02 19:47:40 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2014-05-02 19:47:40 +0000
commit384b041805a3343b4eff7076e8621a84ac03d338 (patch)
tree5f8a43ce0d7d633ca950be8f18dfbaf9acef0cbf /gcc/cp/lambda.c
parentea8c0aad06e706a563cd1bd5fdcbc52c2e59a8f9 (diff)
downloadgcc-384b041805a3343b4eff7076e8621a84ac03d338.tar.gz
PR c++/60992
* lambda.c (lambda_capture_field_type): Wrap anything dependent other than 'this'. (add_capture): Check for VLA before calling it. * semantics.c (is_this_parameter): Accept any 'this' parameter, not just the current one. Make non-static. * cp-tree.h: Declare it. * pt.c (tsubst_copy) [VAR_DECL]: Also build a new VAR_DECL if the operand was static or constant. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210017 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/lambda.c')
-rw-r--r--gcc/cp/lambda.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 0b8b46a8144..5ba6f141b72 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -216,8 +216,8 @@ lambda_capture_field_type (tree expr, bool explicit_init_p)
}
else
type = non_reference (unlowered_expr_type (expr));
- if (!type || WILDCARD_TYPE_P (type) || type_uses_auto (type)
- || DECL_PACK_P (expr))
+ if (type_dependent_expression_p (expr)
+ && !is_this_parameter (tree_strip_nop_conversions (expr)))
{
type = cxx_make_type (DECLTYPE_TYPE);
DECLTYPE_TYPE_EXPR (type) = expr;
@@ -455,7 +455,7 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
if (TREE_CODE (initializer) == TREE_LIST)
initializer = build_x_compound_expr_from_list (initializer, ELK_INIT,
tf_warning_or_error);
- type = lambda_capture_field_type (initializer, explicit_init_p);
+ type = TREE_TYPE (initializer);
if (array_of_runtime_bound_p (type))
{
vla = true;
@@ -482,15 +482,19 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
"variable size", TREE_TYPE (type));
type = error_mark_node;
}
- else if (by_reference_p)
+ else
{
- type = build_reference_type (type);
- if (!real_lvalue_p (initializer))
- error ("cannot capture %qE by reference", initializer);
+ type = lambda_capture_field_type (initializer, explicit_init_p);
+ if (by_reference_p)
+ {
+ type = build_reference_type (type);
+ if (!real_lvalue_p (initializer))
+ error ("cannot capture %qE by reference", initializer);
+ }
+ else
+ /* Capture by copy requires a complete type. */
+ type = complete_type (type);
}
- else
- /* Capture by copy requires a complete type. */
- type = complete_type (type);
/* Add __ to the beginning of the field name so that user code
won't find the field with name lookup. We can't just leave the name