xref: /llvm-project/clang/test/Modules/gh110401.cppm (revision f01364ebc88d875fbfc0e00413538465aaa8a2b3)
1// RUN: rm -rf %t
2// RUN: mkdir %t
3// RUN: split-file %s %t
4//
5// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux -emit-module-interface %t/a.cppm -o %t/A.pcm
6// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux -emit-module-interface -fprebuilt-module-path=%t %t/b.cppm -o %t/B.pcm
7
8// Just check that this doesn't crash.
9
10//--- a.cppm
11module;
12
13template <typename _Visitor>
14void __do_visit(_Visitor &&__visitor) {
15  using _V0 = int;
16  [](_V0 __v) -> _V0 { return __v; } (1);
17}
18
19export module A;
20
21void g() {
22  struct Visitor { };
23  __do_visit(Visitor());
24}
25
26//--- b.cppm
27module;
28
29template <typename _Visitor>
30void __do_visit(_Visitor &&__visitor) {
31  using _V0 = int;
32
33  // Check that we instantiate this lambda's call operator in 'f' below
34  // instead of the one in 'a.cppm' here; otherwise, we won't find a
35  // corresponding instantiation of the using declaration above.
36  [](_V0 __v) -> _V0 { return __v; } (1);
37}
38
39export module B;
40import A;
41
42void f() {
43  __do_visit(1);
44}
45