xref: /llvm-project/clang/test/Modules/pr56916.cppm (revision da00c60dae0040185dc45039c4397f6e746548e9)
1// RUN: rm -rf %t
2// RUN: mkdir %t
3// RUN: split-file %s %t
4//
5// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/M-A.pcm
6// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-module-interface -o %t/M-B.pcm
7// RUN: %clang_cc1 -std=c++20 %t/M.cppm -emit-module-interface -o %t/M.pcm \
8// RUN:     -fprebuilt-module-path=%t
9// RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fsyntax-only -fprebuilt-module-path=%t -verify
10
11// Test again with reduced BMI.
12// RUN: rm -rf %t
13// RUN: mkdir %t
14// RUN: split-file %s %t
15//
16// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-reduced-module-interface -o %t/M-A.pcm
17// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-reduced-module-interface -o %t/M-B.pcm
18// RUN: %clang_cc1 -std=c++20 %t/M.cppm -emit-reduced-module-interface -o %t/M.pcm \
19// RUN:     -fprebuilt-module-path=%t
20// RUN: %clang_cc1 -std=c++20 %t/Use.cpp -fsyntax-only -fprebuilt-module-path=%t -verify
21
22
23//--- foo.h
24template <typename T>
25class Templ {
26public:
27    Templ(T a) {}
28};
29
30//--- A.cppm
31module;
32#include "foo.h"
33export module M:A;
34export using ::Templ;
35
36//--- B.cppm
37module;
38#include "foo.h"
39export module M:B;
40
41//--- M.cppm
42export module M;
43export import :A;
44export import :B;
45
46//--- Use.cpp
47// expected-no-diagnostics
48import M;
49
50void func() {
51    Templ t(5);
52}
53