xref: /llvm-project/clang/test/CXX/module/module.import/p7.cpp (revision b37233a253f30e4bd5f040d598826df443293bee)
1 // RUN: mkdir -p %t
2 // RUN: split-file %s %t
3 
4 // All of the following should build without diagnostics.
5 //
6 // RUN: %clang_cc1 -std=c++20 %t/a.cpp  -emit-module-interface -o %t/a.pcm
7 // R U N: %clang_cc1 -std=c++20 %t/a.pcm  -emit-obj -o %t/a.o
8 //
9 // RUN: %clang_cc1 -std=c++20 %t/b.cpp  -emit-module-interface -o %t/b.pcm \
10 // RUN: -fprebuilt-module-path=%t
11 // R U N: %clang_cc1 -std=c++20 %t/b.pcm  -emit-obj -o %t/b.o
12 //
13 // RUN: %clang_cc1 -std=c++20 %t/b-impl.cpp -emit-obj -o %t/b-impl.o \
14 // RUN: -fprebuilt-module-path=%t
15 //
16 // RUN: %clang_cc1 -std=c++20 %t/ab-main.cpp  -fsyntax-only \
17 // RUN: -fprebuilt-module-path=%t
18 
19 //--- a.cpp
20 
21 export module a;
22 
foo()23 export int foo() {
24    return 42;
25 }
26 
27 //--- b.cpp
28 
29 export module b;
30 import a;
31 
32 export int bar();
33 
34 //--- b-impl.cpp
35 
36 module b;
37 
bar()38 int bar() {
39    return foo();
40 }
41 
42 //--- ab-main.cpp
43 
44 import b;
45 
main()46 int main() {
47    return bar();
48 }
49 
50