diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/lambda.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/lambda-pack-init5.C | 18 |
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 465f290..b89b6d8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2020-04-17 Patrick Palka <ppalka@redhat.com> + PR c++/94483 + * lambda.c (lambda_capture_field_type): Avoid doing auto deduction if + the explicit initializer has parameter packs. + PR c++/88754 * parser.c (cp_parser_check_template_parameters): Before issuing a hard error, first try simulating an error instead. 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)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b80e7da..030550f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2020-04-17 Patrick Palka <ppalka@redhat.com> + PR c++/94483 + * g++.dg/cpp2a/lambda-pack-init5.C: New test. + PR c++/88754 * g++.dg/parse/ambig10.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init5.C b/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init5.C new file mode 100644 index 0000000..492fc47 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init5.C @@ -0,0 +1,18 @@ +// PR c++/94483 +// { dg-do compile { target c++2a } } + +template<int... a> constexpr auto x1 + = [...z = -a] (auto F) { return F(z...); }; + +template<const int&... a> constexpr auto x2 + = [&...z = a] (auto F) { return F(z...); }; + +template<int... a> constexpr auto x3 + = [z = -a] (auto F) { return F(z); }; // { dg-error "packs not expanded" } + + +constexpr auto sum = [] (auto... xs) { return (xs + ... + 0); }; +const int y1 = 1, y2 = 2, y3 = 3; + +static_assert(x1<1,2,3>(sum) == -6); +static_assert(x2<y1,y2,y3>(sum) == 6); |