[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / CXX / module / module.reach / ex1.cpp
bloba1e38c4c88a28857b29e52b11453f7ecf600c4cd
1 // From [module.reach]p4, example 1
2 //
3 // RUN: rm -fr %t
4 // RUN: mkdir -p %t
5 // RUN: split-file %s %t
6 //
7 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/M-A.cppm -o %t/M-A.pcm
8 // RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/M-B-impl.cppm -o %t/M-B.pcm
9 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/M-C.cppm -fsyntax-only -verify
11 // RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/M.cppm -o %t/M.pcm
12 // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/X.cppm -fsyntax-only -verify
14 //--- M-A.cppm
15 export module M:A;
16 export struct B;
18 //--- M-B-impl.cppm
19 module M:B;
20 struct B {
21 operator int();
24 //--- M-C.cppm
25 module M:C;
26 import :A;
27 B b1; // expected-error {{variable has incomplete type 'B'}}
28 // expected-note@* {{forward declaration of 'B'}}
30 //--- M.cppm
31 export module M;
32 export import :A;
33 import :B;
34 B b2;
35 export void f(B b = B());
37 //--- X.cppm
38 export module X;
39 import M;
40 B b3; // expected-error {{definition of 'B' must be imported from module 'M:B' before it is required}} expected-error {{}}
41 // expected-note@* {{definition here is not reachable}} expected-note@* {{}}
42 // FIXME: We should emit an error for unreachable definition of B.
43 void g() { f(); }
44 void g1() { f(B()); } // expected-error 1+{{definition of 'B' must be imported from module 'M:B' before it is required}}
45 // expected-note@* 1+{{definition here is not reachable}}
46 // expected-note@M.cppm:5 {{passing argument to parameter 'b' here}}