Debian Codegraph @

clang/test/Modules/befriend-2.cppm

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir -p %t
3 // RUN: split-file %s %t
4 //
5 // RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/test-A.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/N.cppm -emit-reduced-module-interface -o %t/test-N.pcm
7 // RUN: %clang_cc1 -std=c++20 %t/B.cppm -verify -fsyntax-only -fprebuilt-module-path=%t
8
9 //--- a.h
10 namespace N {
11
12 template <typename>
13 class C {
14 template <typename> friend void foo();
15 };
16
17 template <typename> void foo() {}
18 } // namespace N
19
20 //--- a.cppm
21 // This is some unrelated file. It also #includes system headers, but
22 // here does not even export anything.
23 module;
24 #include "a.h"
25 export module test:A;
26 export {
27 using N::C;
28 using N::foo;
29 }
30
31 //--- std.h
32 // Declarations typically #included from C++ header files:
33 namespace N { // In practice, this would be namespace std
34 inline namespace impl { // In practice, this would be namespace __1
35 template <typename>
36 class C {
37 template <typename> friend void foo();
38 };
39
40 template <typename> void foo() {}
41 } // namespace impl
42 } // namespace N
43
44 //--- N.cppm
45 module;
46 #include "std.h"
47 export module test:N;
48
49 // Now wrap these names into a module and export them:
50 export {
51 namespace N {
52 using N::C;
53 using N::foo;
54 }
55 }
56
57 //--- B.cppm
58 // expected-no-diagnostics
59 // A file that consumes the partitions from the other two files,
60 // including the exported N::C name.
61 module test:B;
62 import :N;
63 import :A;
64
65 N::C<int> x;