xref: /llvm-project/clang/test/Modules/pr71484.cppm (revision 10ad98dc160497699930f295dcb4c998ef561d2e)
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/mod1.cppm -emit-module-interface -o %t/mod1.pcm
6// RUN: %clang_cc1 -std=c++20 %t/mod2.cppm -emit-module-interface -o %t/mod2.pcm \
7// RUN:     -fprebuilt-module-path=%t
8// RUN:  %clang_cc1 -std=c++20 %t/mod3.cppm -fsyntax-only -verify \
9// RUN:     -fprebuilt-module-path=%t
10
11// RUN: %clang_cc1 -std=c++20 %t/mod1.cppm -emit-obj -o %t/mod1.o -fmodule-output=%t/mod1.pcm
12// RUN: %clang_cc1 -std=c++20 %t/mod2.cppm -emit-obj -o %t/mod2.o -fmodule-output=%t/mod2.pcm \
13// RUN:     -fprebuilt-module-path=%t
14// RUN:  %clang_cc1 -std=c++20 %t/mod3.cppm -fsyntax-only -verify \
15// RUN:     -fprebuilt-module-path=%t
16
17//--- mod1.cppm
18export module mod1;
19
20export template<class T>
21T mod1_f(T x) {
22    return x;
23}
24
25//--- mod2.cppm
26export module mod2;
27import mod1;
28
29export template<class U>
30U mod2_g(U y) {
31    return mod1_f(y);
32}
33
34//--- mod3.cppm
35// expected-no-diagnostics
36export module mod3;
37import mod2;
38
39export int mod3_h(int p) {
40    return mod2_g(p);
41}
42