Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Modules / cxx20-10-5-ex1.cpp
bloba83162c5c1501719f3a3c933e87dc5e61b5e2460
1 // RUN: rm -rf %t
2 // RUN: split-file %s %t
3 // RUN: cd %t
5 // RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-5-ex1-interface.cpp \
6 // RUN: -DBAD_FWD_DECL -fsyntax-only -verify
8 // RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-5-ex1-interface.cpp \
9 // RUN: -o A.pcm
11 // RUN: %clang_cc1 -std=c++20 std-10-5-ex1-use.cpp -fmodule-file=A=A.pcm \
12 // RUN: -fsyntax-only -verify
14 //--- std-10-5-ex1-interface.cpp
16 export module A;
17 #ifdef BAD_FWD_DECL
18 export inline void fn_e(); // expected-error {{inline function not defined before the private module fragment}}
19 // expected-note@std-10-5-ex1-interface.cpp:21 {{private module fragment begins here}}
20 #endif
21 export inline void ok_fn() {}
22 export inline void ok_fn2();
23 #ifdef BAD_FWD_DECL
24 inline void fn_m(); // expected-error {{inline function not defined before the private module fragment}}
25 // expected-note@std-10-5-ex1-interface.cpp:21 {{private module fragment begins here}}
26 #endif
27 static void fn_s();
28 export struct X;
29 export void g(X *x) {
30 fn_s();
32 export X *factory();
33 void ok_fn2() {}
35 module :private;
36 struct X {};
37 X *factory() {
38 return new X();
41 void fn_e() {}
42 void fn_m() {}
43 void fn_s() {}
45 //--- std-10-5-ex1-use.cpp
47 import A;
49 void foo() {
50 X x; // expected-error 1+{{missing '#include'; 'X' must be defined before it is used}}
51 // expected-note@std-10-5-ex1-interface.cpp:22 1+{{definition here is not reachable}}
52 X *p = factory();