Files
gcc-reflection/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init6.C
Jason Merrill 2a26351b59 c++: lambda pack init-capture within generic lambda
We represent the type of a pack init-capture as auto... with packs from the
initializer stuck into PACK_EXPANSION_PARAMETER_PACKS so that expanding it
produces the right number of elements.  But when partially instantiating the
auto..., we were changing PACK_EXPANSION_PARAMETER_PACKS to refer to only
the auto itself.  Fixed thus.

gcc/cp/ChangeLog:

	PR c++/97938
	* cp-tree.h (PACK_EXPANSION_AUTO_P): New.
	* lambda.c (add_capture): Set it.
	* pt.c (tsubst_pack_expansion): Handle it.

gcc/testsuite/ChangeLog:

	PR c++/97938
	* g++.dg/cpp2a/lambda-pack-init6.C: New test.
2021-04-02 12:46:54 -04:00

28 lines
423 B
C

// PR c++/97938
// { dg-do compile { target c++20 } }
template <typename... Args>
int sink(Args&&... args) { return 2; }
auto fwd1(const auto&&... ts1) {
return
[...ts1 = ts1] {
return sink(ts1...);
}();
}
template <typename T1>
auto fwd2(const T1& t1) {
return
[] (auto&&... ts1) {
return
[...ts1 = ts1] {
return sink(ts1...);
}();
}();
}
int main() {
return fwd1() + fwd2(1);
}