aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/lambda.c
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2020-04-16 10:28:23 -0400
committerPatrick Palka <ppalka@redhat.com>2020-04-17 14:00:41 -0400
commita28edad3da5c59f09565d3d42e20be1a924986c4 (patch)
treeb0f433a9d4ef91610f1a5157f0603c3481227762 /gcc/cp/lambda.c
parent3f5af3f71195b7f1ebe32bd0d695b59904fff778 (diff)
downloadgcc-a28edad3da5c59f09565d3d42e20be1a924986c4.zip
gcc-a28edad3da5c59f09565d3d42e20be1a924986c4.tar.gz
gcc-a28edad3da5c59f09565d3d42e20be1a924986c4.tar.bz2
c++: Non-type-dependent variadic lambda init-capture [PR94483]
In this PR, we're ICEing on a use of an 'int... a' template parameter pack as part of the variadic lambda init-capture [...z=a]. The unexpected thing about this variadic init-capture is that it is not type-dependent, and so the call to do_auto_deduction from lambda_capture_field_type actually resolves its type to 'int' instead of exiting early like it does for a type-dependent variadic initializer. This later confuses add_capture which, according to one of its comments, assumes that 'type' is always 'auto' for a variadic init-capture. The simplest fix (and the approach that this patch takes) seems to be to avoid doing auto deduction in lambda_capture_field_type when the initializer uses parameter packs, so that we always return 'auto' even in the non-type-dependent case. gcc/cp/ChangeLog: PR c++/94483 * lambda.c (lambda_capture_field_type): Avoid doing auto deduction if the explicit initializer has parameter packs. gcc/testsuite/ChangeLog: PR c++/94483 * g++.dg/cpp2a/lambda-pack-init5.C: New test.
Diffstat (limited to 'gcc/cp/lambda.c')
-rw-r--r--gcc/cp/lambda.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index 4f39f99..b55c2f8 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -223,7 +223,10 @@ lambda_capture_field_type (tree expr, bool explicit_init_p,
/* Add the reference now, so deduction doesn't lose
outermost CV qualifiers of EXPR. */
type = build_reference_type (type);
- type = do_auto_deduction (type, expr, auto_node);
+ if (uses_parameter_packs (expr))
+ /* Stick with 'auto' even if the type could be deduced. */;
+ else
+ type = do_auto_deduction (type, expr, auto_node);
}
else if (!is_this && type_dependent_expression_p (expr))
{