Skip to content

Commit 2241146

Browse files
committed
[NFC] [C++20] [Modules] Add a test for merging lambda types
Close #57222. This should be fixed with the series of bc73ef0. Add the test case for C++20 Named modules.
1 parent 4d8cf2a commit 2241146

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

clang/test/Modules/merge-lambdas.cppm

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir %t
3+
// RUN: split-file %s %t
4+
//
5+
// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm
6+
// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-module-interface -o %t/B.pcm
7+
// RUN: %clang_cc1 -std=c++20 %t/use.cppm -fprebuilt-module-path=%t -fsyntax-only -verify
8+
9+
//--- lambda.h
10+
inline auto cmp = [](auto l, auto r) {
11+
return l < r;
12+
};
13+
14+
//--- A.cppm
15+
module;
16+
#include "lambda.h"
17+
18+
export module A;
19+
export auto c1 = cmp;
20+
export using ::cmp;
21+
22+
//--- B.cppm
23+
module;
24+
#include "lambda.h"
25+
26+
export module B;
27+
export auto c2 = cmp;
28+
export using ::cmp;
29+
30+
//--- use.cppm
31+
// expected-no-diagnostics
32+
module;
33+
34+
export module use;
35+
36+
import A;
37+
import B;
38+
39+
static_assert(__is_same(decltype(c1), decltype(c2))); // should succeed.
40+
auto x = cmp; // cmp must not be ambiguous,

0 commit comments

Comments
 (0)