aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/lambda.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2014-05-02 15:47:40 -0400
committerJason Merrill <jason@gcc.gnu.org>2014-05-02 15:47:40 -0400
commit43b781fac7673ac9f11105048ccc2a75c8a9f0c3 (patch)
tree5f8a43ce0d7d633ca950be8f18dfbaf9acef0cbf /gcc/cp/lambda.c
parent62da5a07b2f56f860e70c9bb66791ac665bf14d8 (diff)
downloadgcc-43b781fac7673ac9f11105048ccc2a75c8a9f0c3.zip
gcc-43b781fac7673ac9f11105048ccc2a75c8a9f0c3.tar.gz
gcc-43b781fac7673ac9f11105048ccc2a75c8a9f0c3.tar.bz2
re PR c++/60992 (ICE in tsubst_copy, at cp/pt.c:12637)
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. From-SVN: r210017
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 0b8b46a..5ba6f14 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