66 lines · cpp
1// RUN: rm -rf %t2// RUN: split-file %s %t3// RUN: cd %t4 5// RUN: %clang_cc1 -std=c++20 std-10-5-ex1-interface.cpp \6// RUN: -DBAD_FWD_DECL -fsyntax-only -verify7 8// RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-5-ex1-interface.cpp \9// RUN: -o A.pcm10 11// RUN: %clang_cc1 -std=c++20 std-10-5-ex1-use.cpp -fmodule-file=A=A.pcm \12// RUN: -fsyntax-only -verify13 14// Test again with reduced BMI.15// RUN: rm A.pcm16// RUN: %clang_cc1 -std=c++20 std-10-5-ex1-interface.cpp \17// RUN: -DBAD_FWD_DECL -fsyntax-only -verify18 19// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface std-10-5-ex1-interface.cpp \20// RUN: -o A.pcm21 22// RUN: %clang_cc1 -std=c++20 std-10-5-ex1-use.cpp -fmodule-file=A=A.pcm \23// RUN: -fsyntax-only -verify24 25 26//--- std-10-5-ex1-interface.cpp27 28export module A;29#ifdef BAD_FWD_DECL30export inline void fn_e(); // expected-error {{inline function not defined before the private module fragment}}31 // expected-note@std-10-5-ex1-interface.cpp:21 {{private module fragment begins here}}32#endif33export inline void ok_fn() {}34export inline void ok_fn2();35#ifdef BAD_FWD_DECL36inline void fn_m(); // expected-error {{inline function not defined before the private module fragment}}37 // expected-note@std-10-5-ex1-interface.cpp:21 {{private module fragment begins here}}38#endif39static void fn_s();40export struct X;41export void g(X *x) {42 fn_s();43}44export X *factory();45void ok_fn2() {}46 47module :private;48struct X {};49X *factory() {50 return new X();51}52 53void fn_e() {}54void fn_m() {}55void fn_s() {}56 57//--- std-10-5-ex1-use.cpp58 59import A;60 61void foo() {62 X x; // expected-error 1+{{missing '#include'; 'X' must be defined before it is used}}63 // expected-note@std-10-5-ex1-interface.cpp:22 1+{{definition here is not reachable}}64 X *p = factory();65}66