aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/lambda.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2019-02-28 19:08:21 -0500
committerJason Merrill <jason@gcc.gnu.org>2019-02-28 19:08:21 -0500
commit1eb7a0850bfe34f3bae0681a0032e4cbb3adaa17 (patch)
treea957a50236f95718097159817b065bac51847875 /gcc/cp/lambda.c
parentfbfef5060f5dd9ae2b23435f60e3101dfe8f7012 (diff)
downloadgcc-1eb7a0850bfe34f3bae0681a0032e4cbb3adaa17.zip
gcc-1eb7a0850bfe34f3bae0681a0032e4cbb3adaa17.tar.gz
gcc-1eb7a0850bfe34f3bae0681a0032e4cbb3adaa17.tar.bz2
PR c++/86969 - ICE with constexpr if and recursive generic lambdas.
* class.c, lambda.c, pt.c: Revert earlier change. * lambda.c (add_capture): Don't special-case capture of dependent VLA. From-SVN: r269292
Diffstat (limited to 'gcc/cp/lambda.c')
-rw-r--r--gcc/cp/lambda.c30
1 files changed, 4 insertions, 26 deletions
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index c25df2f..e7f0fda 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -479,31 +479,9 @@ static GTY(()) tree max_id;
an array of runtime length. */
static tree
-vla_capture_type (tree array_type, tree lambda)
+vla_capture_type (tree array_type)
{
- tree closure = LAMBDA_EXPR_CLOSURE (lambda);
- tree type = make_class_type (RECORD_TYPE);
- cp_binding_level *slev = current_binding_level;
- if (closure)
- {
- /* If we're already inside the lambda body, force the capture type out
- into the enclosing context, so we don't crash trying to instantiate
- the capture field in tsubst_lambda_expr. We won't have a TAG_DEFN
- from finish_struct in the enclosing context, which we work around in
- tsubst_lambda_expr. */
- TYPE_CONTEXT (type) = TYPE_CONTEXT (closure);
- cp_binding_level *b = current_binding_level;
- for (;; b = b->level_chain)
- if (b->this_entity == closure)
- {
- while (b->this_entity == closure)
- b = b->level_chain;
- break;
- }
- current_binding_level = b;
- }
- type = pushtag (make_anon_name (), type, ts_current);
- current_binding_level = slev;
+ tree type = xref_tag (record_type, make_anon_name (), ts_current, false);
xref_basetypes (type, NULL_TREE);
type = begin_class_definition (type);
if (!ptr_id)
@@ -549,7 +527,7 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
if (type == error_mark_node)
return error_mark_node;
- if (array_of_runtime_bound_p (type))
+ if (!dependent_type_p (type) && array_of_runtime_bound_p (type))
{
vla = true;
if (!by_reference_p)
@@ -563,7 +541,7 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
initializer = build_constructor_va (init_list_type_node, 2,
NULL_TREE, build_address (elt),
NULL_TREE, array_type_nelts (type));
- type = vla_capture_type (type, lambda);
+ type = vla_capture_type (type);
}
else if (!dependent_type_p (type)
&& variably_modified_type_p (type, NULL_TREE))