c++: Support lambdas in static template member initialisers [PR107398]
commitcff1fa6625d1273fcfaf473e436ba918262d8afa
authorNathaniel Shead <nathanieloshead@gmail.com>
Mon, 13 Nov 2023 09:11:15 +0000 (13 20:11 +1100)
committerNathaniel Shead <nathanieloshead@gmail.com>
Fri, 24 Nov 2023 02:31:11 +0000 (24 13:31 +1100)
treead684b104ddd587a4ffb66c3ce824ac5f9612985
parenta1f8e65dee2d9e929cd083f36501d08bdc9c8072
c++: Support lambdas in static template member initialisers [PR107398]

The testcase noted in the PR fails because the context of the lambda is
not in namespace scope, but rather in class scope. This patch removes
the assertion that the context must be a namespace and ensures that
lambdas in class scope still get the correct merge_kind.

PR c++/107398

gcc/cp/ChangeLog:

* module.cc (trees_out::get_merge_kind): Handle lambdas in class
scope.
(maybe_key_decl): Remove assertion and fix whitespace.

gcc/testsuite/ChangeLog:

* g++.dg/modules/lambda-6_a.C: New test.
* g++.dg/modules/lambda-6_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
gcc/cp/module.cc
gcc/testsuite/g++.dg/modules/lambda-6_a.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/lambda-6_b.C [new file with mode: 0644]