xref: /llvm-project/clang/test/Modules/pr63595.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 -emit-module-interface -I%t %t/module1.cppm -o %t/module1.pcm
6// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/module2.cppm -o %t/module2.pcm
7// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/merge.cpp -verify -fsyntax-only
8
9// Test again with reduced BMI.
10// RUN: rm -rf %t
11// RUN: mkdir %t
12// RUN: split-file %s %t
13//
14// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface -I%t %t/module1.cppm -o %t/module1.pcm
15// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface -I%t %t/module2.cppm -o %t/module2.pcm
16// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/merge.cpp -verify -fsyntax-only
17
18
19//--- header.h
20namespace NS {
21template <int I>
22class A {
23};
24
25template <template <int I_> class T>
26class B {
27};
28}
29
30//--- module1.h
31namespace NS {
32using C = B<A>;
33}
34struct D : NS::C {
35    using Type = NS::C;
36};
37
38//--- module1.cppm
39// inside NS, using C = B<A>
40module;
41#include "header.h"
42#include "module1.h"
43export module module1;
44export using ::D;
45
46//--- module2.h
47namespace NS {
48using C = B<NS::A>;
49}
50struct D : NS::C {
51    using Type = NS::C;
52};
53
54//--- module2.cppm
55// inside NS, using C = B<NS::A>
56module;
57#include "header.h"
58#include "module2.h"
59export module module2;
60export using ::D;
61
62//--- merge.cpp
63// expected-no-diagnostics
64import module1;
65import module2;
66D d;
67