1 // RUN: rm -rf %t
2 // RUN: mkdir -p %t
3 // RUN: split-file %s %t
4 // RUN: %clang_cc1 -std=c++20 %t/impl.cppm -emit-module-interface -o %t/M-impl.pcm
5 // RUN: %clang_cc1 -std=c++20 %t/M.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/M.pcm
6 // RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fprebuilt-module-path=%t -verify -fsyntax-only
7 // RUN: %clang_cc1 -std=c++20 %t/UseInPartA.cppm -fprebuilt-module-path=%t -verify -fsyntax-only
8 // RUN: %clang_cc1 -std=c++20 %t/UseInAnotherModule.cppm -fprebuilt-module-path=%t -verify -fsyntax-only
9 // RUN: %clang_cc1 -std=c++20 %t/Private.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/A.pcm
10 // RUN: %clang_cc1 -std=c++20 %t/TryUseFromPrivate.cpp -fprebuilt-module-path=%t -verify -fsyntax-only
11 // RUN: %clang_cc1 -std=c++20 %t/Global.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/C.pcm
12 // RUN: %clang_cc1 -std=c++20 %t/UseGlobal.cpp -fprebuilt-module-path=%t -verify -fsyntax-only
13 
14 //--- impl.cppm
15 module M:impl;
16 class A {};
17 
18 //--- M.cppm
19 export module M;
20 import :impl;
21 export A f();
22 
23 //--- Use.cpp
24 import M;
25 void test() {
26   A a; // expected-error {{unknown type name 'A'}}
27 }
28 
29 //--- UseInPartA.cppm
30 // expected-no-diagnostics
31 export module M:partA;
32 import :impl;
33 void test() {
34   A a;
35 }
36 
37 //--- UseInAnotherModule.cppm
38 export module B;
39 import M;
40 void test() {
41   A a; // expected-error {{unknown type name 'A'}}
42 }
43 
44 //--- Private.cppm
45 export module A;
46 module :private;
47 
48 class A {};
49 void test() {
50   A a;
51 }
52 
53 //--- TryUseFromPrivate.cpp
54 
55 import A;
56 void test() {
57   A a; // expected-error {{unknown type name 'A'}}
58 }
59 
60 //--- Global.cppm
61 module;
62 class A{};
63 export module C;
64 void test() {
65   A a;
66 }
67 
68 //--- UseGlobal.cpp
69 import C;
70 void test() {
71   A a; // expected-error {{'A' must be declared before it is used}}
72        // [email protected]:2 {{declaration here is not visible}}
73 }
74