67 lines · cpp
1// The example in the standard is not in required build order.2// revised here3 4// RUN: rm -rf %t5// RUN: mkdir -p %t6// RUN: split-file %s %t7 8// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex1-tu1.cpp \9// RUN: -o %t/A_Internals.pcm10 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.pcm13 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.pcm17 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.o21 22// RUN: rm %t/A_Internals.pcm %t/A_Foo.pcm %t/A.pcm23// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-1-ex1-tu1.cpp \24// RUN: -o %t/A_Internals.pcm25 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.pcm28 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.pcm32 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.o37 38// expected-no-diagnostics39 40//--- std10-1-ex1-tu1.cpp41 42module A:Internals;43int bar();44 45//--- std10-1-ex1-tu2.cpp46 47export module A:Foo;48 49import :Internals;50 51export int foo() { return 2 * (bar() + 1); }52 53//--- std10-1-ex1-tu3.cpp54 55export module A;56export import :Foo;57export int baz();58 59//--- std10-1-ex1-tu4.cpp60 61module A;62 63import :Internals;64 65int bar() { return baz() - 10; }66int baz() { return 30; }67