| 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 |
| 10 |
// |
| 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 |
| 13 |
// |
| 14 |
//--- M-A.cppm |
| 15 |
export module M:A; |
| 16 |
export struct B; |
| 17 |
|
| 18 |
//--- M-B-impl.cppm |
| 19 |
module M:B; |
| 20 |
struct B { |
| 21 |
operator int(); |
| 22 |
}; |
| 23 |
|
| 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'}} |
| 29 |
|
| 30 |
//--- M.cppm |
| 31 |
export module M; |
| 32 |
export import :A; |
| 33 |
import :B; |
| 34 |
B b2; |
| 35 |
export void f(B b = B()); |
| 36 |
|
| 37 |
//--- X.cppm |
| 38 |
export module X; |
| 39 |
import M; |
| 40 |
B b3; // expected-error {{definition of 'B' must be imported from module 'M' 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' before it is required}} |
| 45 |
// expected-note@* 1+{{definition here is not reachable}} |
| 46 |
// [email protected]:5 {{passing argument to parameter 'b' here}} |