Debian Codegraph @

clang/test/Modules/cxx20-10-1-ex1.cpp

raw
1 // The example in the standard is not in required build order.
2 // revised here
3
4 // RUN: rm -rf %t
5 // RUN: mkdir -p %t
6 // RUN: split-file %s %t
7
8 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex1-tu1.cpp \
9 // RUN: -o %t/A_Internals.pcm
10
11 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex1-tu2.cpp \
12 // RUN: -fmodule-file=A:Internals=%t/A_Internals.pcm -o %t/A_Foo.pcm
13
14 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex1-tu3.cpp \
15 // RUN: -fmodule-file=A:Foo=%t/A_Foo.pcm -fmodule-file=A:Internals=%t/A_Internals.pcm \
16 // RUN: -o %t/A.pcm
17
18 // RUN: %clang_cc1 -std=c++20 -emit-obj %t/std10-1-ex1-tu4.cpp \
19 // RUN: -fmodule-file=A=%t/A.pcm -fmodule-file=A:Foo=%t/A_Foo.pcm \
20 // RUN: -fmodule-file=A:Internals=%t/A_Internals.pcm -o %t/ex1.o
21
22 // RUN: rm %t/A_Internals.pcm %t/A_Foo.pcm %t/A.pcm
23 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-1-ex1-tu1.cpp \
24 // RUN: -o %t/A_Internals.pcm
25
26 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-1-ex1-tu2.cpp \
27 // RUN: -fmodule-file=A:Internals=%t/A_Internals.pcm -o %t/A_Foo.pcm
28
29 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-1-ex1-tu3.cpp \
30 // RUN: -fmodule-file=A:Internals=%t/A_Internals.pcm \
31 // RUN: -fmodule-file=A:Foo=%t/A_Foo.pcm -o %t/A.pcm
32
33 // RUN: %clang_cc1 -std=c++20 -emit-obj %t/std10-1-ex1-tu4.cpp \
34 // RUN: -fmodule-file=A:Internals=%t/A_Internals.pcm \
35 // RUN: -fmodule-file=A:Foo=%t/A_Foo.pcm \
36 // RUN: -fmodule-file=A=%t/A.pcm -o %t/ex1.o
37
38 // expected-no-diagnostics
39
40 //--- std10-1-ex1-tu1.cpp
41
42 module A:Internals;
43 int bar();
44
45 //--- std10-1-ex1-tu2.cpp
46
47 export module A:Foo;
48
49 import :Internals;
50
51 export int foo() { return 2 * (bar() + 1); }
52
53 //--- std10-1-ex1-tu3.cpp
54
55 export module A;
56 export import :Foo;
57 export int baz();
58
59 //--- std10-1-ex1-tu4.cpp
60
61 module A;
62
63 import :Internals;
64
65 int bar() { return baz() - 10; }
66 int baz() { return 30; }