xref: /llvm-project/clang/test/Modules/cxx20-10-3-ex2.cpp (revision da00c60dae0040185dc45039c4397f6e746548e9)
1 // RUN: rm -rf %t
2 // RUN: mkdir -p %t
3 // RUN: split-file %s %t
4 
5 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-3-ex2-tu1.cpp \
6 // RUN:  -o %t/M.pcm
7 
8 // RUN: %clang_cc1 -std=c++20 -S %t/std10-3-ex2-tu2.cpp \
9 // RUN:  -fmodule-file=M=%t/M.pcm -o %t/tu_8.s -verify
10 
11 // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-3-ex2-tu3.cpp \
12 // RUN:  -o %t/M.pcm -verify
13 
14 // Test again with reduced BMI.
15 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-3-ex2-tu1.cpp \
16 // RUN:  -o %t/M.pcm
17 
18 // RUN: %clang_cc1 -std=c++20 -S %t/std10-3-ex2-tu2.cpp \
19 // RUN:  -fmodule-file=M=%t/M.pcm -o %t/tu_8.s -verify
20 
21 // RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/std10-3-ex2-tu3.cpp \
22 // RUN:  -o %t/M.pcm -verify
23 
24 //--- std10-3-ex2-tu1.cpp
25 export module M;
26 
27 //--- std10-3-ex2-tu2.cpp
28 module M;
29           // error: cannot import M in its own unit
30 import M; // expected-error {{import of module 'M' appears within its own implementation}}
31 
32 //--- std10-3-ex2-tu3.cpp
33 export module M;
34           // error: cannot import M in its own unit
35 import M; // expected-error {{import of module 'M' appears within its own interface}}
36