mirrored from git://gcc.gnu.org/git/gcc.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
3 changed files
with
48 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// PR c++/107398 | ||
// { dg-additional-options "-fmodules-ts" } | ||
// { dg-module-cmi Lambda6 } | ||
|
||
export module Lambda6; | ||
|
||
template <typename T> | ||
struct R { static int x; }; | ||
|
||
template <typename T> | ||
int R<T>::x = []{int i; return 1;}(); | ||
|
||
export int foo(); | ||
int foo() { | ||
return R<int>::x; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// PR c++/107398 | ||
// { dg-additional-options "-fmodules-ts" } | ||
|
||
import Lambda6; | ||
|
||
int main() { | ||
if (foo() != 1) | ||
__builtin_abort(); | ||
} |