c++: nested lambda capture pack [PR119345]

tsubst_stmt already registers a local capture proxy as a
local_specialization of both an outer capture proxy and the captured
variable; we also need to do that in add_extra_args.

	PR c++/119345

gcc/cp/ChangeLog:

	* pt.cc (add_extra_args): Also register a specialization
	of the captured variable.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-targ14.C: New test.
This commit is contained in:
Jason Merrill 2025-04-10 14:34:35 -04:00
parent 733a6a4c11
commit 5957b9919c
2 changed files with 14 additions and 0 deletions

View file

@ -13748,6 +13748,8 @@ add_extra_args (tree extra, tree args, tsubst_flags_t complain, tree in_decl)
inst = local;
/* else inst is already a full instantiation of the pack. */
register_local_specialization (inst, gen);
if (is_normal_capture_proxy (gen))
register_local_specialization (inst, DECL_CAPTURED_VARIABLE (gen));
}
gcc_assert (!TREE_PURPOSE (extra));
extra = TREE_VALUE (extra);

View file

@ -0,0 +1,12 @@
// PR c++/119345
// { dg-do compile { target c++20 } }
void f(auto... args) {
[args...]<int... i> {
(..., [args...] { i; });
}.template operator()<0>();
}
int main() {
f();
}