]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Clear lambda scope for unattached member template lambdas
authorNathaniel Shead <nathanieloshead@gmail.com>
Fri, 31 Jan 2025 12:01:15 +0000 (23:01 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Fri, 14 Feb 2025 01:14:52 +0000 (12:14 +1100)
commit8caf67eea7e1b29a4437f07d13c300d9fdb04827
tree9b2124aafa685d02520cce8bce6b5243b1fc2f58
parent12feb78be517472ca941953dce47d6e78e5a17f8
c++: Clear lambda scope for unattached member template lambdas

In r15-7202 we made lambdas between a template parameter scope and a
class/function/initializer be considered TU-local, in lieu of working
out how to mangle them to the succeeding declaration.

I neglected to clear any existing mangling on the template declaration
however; this means that such lambdas can occasionally get a lambda
scope, and will in general inherit the lambda scope of their
instantiation context (whatever that might be).

This patch ensures that the scope is cleared on the template declaration
as well.

gcc/cp/ChangeLog:

* lambda.cc (record_lambda_scope): Clear mangling scope for
otherwise unattached lambdas in class member templates.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-uneval22.C: Add check that the primary
specialisation of the lambda is TU-local.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
gcc/cp/lambda.cc
gcc/testsuite/g++.dg/cpp2a/lambda-uneval22.C