47 lines · cpp
1// From [module.reach]p4, example 12//3// RUN: rm -fr %t4// RUN: mkdir -p %t5// RUN: split-file %s %t6//7// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/M-A.cppm -o %t/M-A.pcm8// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/M-B-impl.cppm -o %t/M-B.pcm9// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/M-C.cppm -fsyntax-only -verify10//11// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/M.cppm -o %t/M.pcm12// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/X.cppm -fsyntax-only -verify13//14//--- M-A.cppm15export module M:A;16export struct B;17 18//--- M-B-impl.cppm19module M:B;20struct B {21 operator int();22};23 24//--- M-C.cppm25module M:C;26import :A;27B b1; // expected-error {{variable has incomplete type 'B'}}28 // expected-note@* {{forward declaration of 'B'}}29 30//--- M.cppm31export module M;32export import :A;33import :B;34B b2;35export void f(B b = B());36 37//--- X.cppm38export module X;39import M;40B 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.43void g() { f(); }44void 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 // expected-note@M.cppm:5 {{passing argument to parameter 'b' here}}47