[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / cxx20-10-3-ex1.cpp
blob82ecb40df910fa92c02ec4cac095b822655b6973
1 // RUN: rm -rf %t
2 // RUN: mkdir -p %t
3 // RUN: split-file %s %t
5 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-3-ex1-tu1.cpp \
6 // RUN: -o %t/M_PartImpl.pcm
8 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-3-ex1-tu2.cpp \
9 // RUN: -fmodule-file=M:PartImpl=%t/M_PartImpl.pcm -o %t/M.pcm -verify
11 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-3-ex1-tu3.cpp \
12 // RUN: -o %t/M_Part.pcm
14 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-3-ex1-tu4.cpp \
15 // RUN: -fmodule-file=M:Part=%t/M_Part.pcm -o %t/M.pcm
17 // Test again with reduced BMI.
18 // RUN: rm %t/M_PartImpl.pcm %t/M.pcm %t/M_Part.pcm
19 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-3-ex1-tu1.cpp \
20 // RUN: -o %t/M_PartImpl.pcm
22 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-3-ex1-tu2.cpp \
23 // RUN: -fmodule-file=M:PartImpl=%t/M_PartImpl.pcm -o %t/M.pcm -verify
25 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-3-ex1-tu3.cpp \
26 // RUN: -o %t/M_Part.pcm
28 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-3-ex1-tu4.cpp \
29 // RUN: -fmodule-file=M:Part=%t/M_Part.pcm -o %t/M.pcm
31 //--- std10-3-ex1-tu1.cpp
32 module M:PartImpl;
34 // expected-no-diagnostics
36 //--- std10-3-ex1-tu2.cpp
37 export module M;
38 // error: exported partition :Part is an implementation unit
39 export import :PartImpl; // expected-error {{module partition implementations cannot be exported}}
40 // expected-warning@-1 {{importing an implementation partition unit in a module interface is not recommended.}}
42 //--- std10-3-ex1-tu3.cpp
43 export module M:Part;
45 // expected-no-diagnostics
47 //--- std10-3-ex1-tu4.cpp
48 export module M;
49 export import :Part;
51 // expected-no-diagnostics