xref: /llvm-project/clang/test/Modules/cxx20-named-conditionally-load.cppm (revision 1782e8f9e882e8f4fb59968ff555c8c93827ea02)
1// RUN: rm -rf %t
2// RUN: mkdir -p %t
3// RUN: split-file %s %t
4//
5// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
6// RUN: %clang_cc1 -std=c++20 %t/b.cppm -fmodule-file=a=%t/a.pcm -fsyntax-only -verify
7// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fmodule-file=a=%t/a.pcm -fsyntax-only -verify
8//
9// RUN: %clang_cc1 -std=c++20 %t/M-Part.cppm -emit-module-interface -o %t/M-Part.pcm
10// RUN: %clang_cc1 -std=c++20 %t/M.cppm -fmodule-file=M:Part=%t/M-Part.pcm -fsyntax-only -verify
11
12//--- a.cppm
13export module a;
14export int foo() { return 43; }
15
16//--- b.cppm
17// expected-no-diagnostics
18export module b;
19import a;
20export int b() {
21    return foo();
22}
23
24//--- use.cpp
25// expected-no-diagnostics
26import a;
27int Use() {
28    return foo();
29}
30
31//--- M-Part.cppm
32export module M:Part;
33
34//--- M.cppm
35// expected-no-diagnostics
36export module M;
37import :Part;
38