Debian Codegraph @

clang/test/Modules/transitive-import.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/Invisible.cppm -emit-module-interface -o %t/Invisible.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/Other.cppm -emit-module-interface -fprebuilt-module-path=%t \
7 // RUN: -o %t/Other.pcm
8 // RUN: %clang_cc1 -std=c++20 %t/Another.cppm -emit-module-interface -o %t/Another.pcm
9 // RUN: %clang_cc1 -std=c++20 %t/A-interface.cppm -emit-module-interface \
10 // RUN: -fprebuilt-module-path=%t -o %t/A-interface.pcm
11 // RUN: %clang_cc1 -std=c++20 %t/A-interface2.cppm -emit-module-interface \
12 // RUN: -fprebuilt-module-path=%t -o %t/A-interface2.pcm
13 // RUN: %clang_cc1 -std=c++20 %t/A-interface3.cppm -emit-module-interface \
14 // RUN: -fprebuilt-module-path=%t -o %t/A-interface3.pcm
15 // RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface \
16 // RUN: -fprebuilt-module-path=%t -o %t/A.pcm
17
18 // RUN: %clang_cc1 -std=c++20 %t/A.cpp -fprebuilt-module-path=%t -fsyntax-only -verify
19 // RUN: %clang_cc1 -std=c++20 %t/A-impl.cppm -fprebuilt-module-path=%t -fsyntax-only -verify
20
21 // RUN: %clang_cc1 -std=c++20 %t/A-impl2.cppm -fprebuilt-module-path=%t -fsyntax-only -verify
22
23 //--- Invisible.cppm
24 export module Invisible;
25 export void invisible() {}
26
27 //--- Other.cppm
28 export module Other;
29 import Invisible;
30 export void other() {}
31
32 //--- Another.cppm
33 export module Another;
34 export void another() {}
35
36 //--- A-interface.cppm
37 export module A:interface;
38 import Other;
39 export void a_interface() {}
40
41 //--- A-interface2.cppm
42 export module A:interface2;
43 import Another;
44 export void a_interface2() {}
45
46 //--- A-interface3.cppm
47 export module A:interface3;
48 import :interface;
49 import :interface2;
50 export void a_interface3() {}
51
52 //--- A.cppm
53 export module A;
54 import Another;
55 import :interface;
56 import :interface2;
57 import :interface3;
58
59 export void a() {}
60 export void impl();
61
62 //--- A.cpp
63 module A;
64 void impl() {
65 a_interface();
66 a_interface2();
67 a_interface3();
68
69 other();
70 another();
71
72 invisible(); // expected-error {{declaration of 'invisible' must be imported from module 'Invisible' before it is required}}
73 // expected-note@* {{declaration here is not visible}}
74 }
75
76 //--- A-impl.cppm
77 module A:impl;
78 import :interface3;
79
80 void impl_part() {
81 a_interface();
82 a_interface2();
83 a_interface3();
84
85 other();
86 another();
87
88 invisible(); // expected-error {{declaration of 'invisible' must be imported from module 'Invisible' before it is required}}
89 // expected-note@* {{declaration here is not visible}}
90 }
91
92 //--- A-impl2.cppm
93 module A:impl2;
94 import A;
95
96 void impl_part2() {
97 a();
98 impl();
99
100 a_interface();
101 a_interface2();
102 a_interface3();
103
104 other();
105 another();
106
107 invisible(); // expected-error {{declaration of 'invisible' must be imported from module 'Invisible' before it is required}}
108 // expected-note@* {{declaration here is not visible}}
109 }