Skip to content

Commit f8d317c

Browse files
committed
[C++20][Modules][Serialization] Add a unit test for #121245.
1 parent d4159e2 commit f8d317c

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

clang/test/Modules/pr121245.cpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: split-file %s %t
4+
// RUN: cd %t
5+
6+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-01.h \
7+
// RUN: -fcxx-exceptions -o %t/hu-01.pcm
8+
9+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-02.h \
10+
// RUN: -Wno-experimental-header-units -fcxx-exceptions \
11+
// RUN: -fmodule-file=%t/hu-01.pcm -o %t/hu-02.pcm
12+
13+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-03.h \
14+
// RUN: -Wno-experimental-header-units -fcxx-exceptions \
15+
// RUN: -fmodule-file=%t/hu-01.pcm -o %t/hu-03.pcm
16+
17+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-04.h \
18+
// RUN: -Wno-experimental-header-units -fcxx-exceptions \
19+
// RUN: -fmodule-file=%t/hu-01.pcm -o %t/hu-04.pcm
20+
21+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-05.h \
22+
// RUN: -Wno-experimental-header-units -fcxx-exceptions \
23+
// RUN: -fmodule-file=%t/hu-03.pcm -fmodule-file=%t/hu-04.pcm \
24+
// RUN: -fmodule-file=%t/hu-01.pcm -o %t/hu-05.pcm
25+
26+
// RUN: %clang_cc1 -std=c++20 -emit-obj %t/main.cpp \
27+
// RUN: -Wno-experimental-header-units -fcxx-exceptions \
28+
// RUN: -fmodule-file=%t/hu-02.pcm -fmodule-file=%t/hu-05.pcm \
29+
// RUN: -fmodule-file=%t/hu-04.pcm -fmodule-file=%t/hu-03.pcm \
30+
// RUN: -fmodule-file=%t/hu-01.pcm
31+
32+
//--- hu-01.h
33+
template <typename T>
34+
struct A {
35+
A() {}
36+
~A() {}
37+
};
38+
39+
template <typename T>
40+
struct EBO : T {
41+
EBO() = default;
42+
};
43+
44+
template <typename T>
45+
struct HT : EBO<A<T>> {};
46+
47+
//--- hu-02.h
48+
import "hu-01.h";
49+
50+
inline void f() {
51+
HT<int>();
52+
}
53+
54+
//--- hu-03.h
55+
import "hu-01.h";
56+
57+
struct C {
58+
C();
59+
60+
HT<long> _;
61+
};
62+
63+
//--- hu-04.h
64+
import "hu-01.h";
65+
66+
void g(HT<long> = {});
67+
68+
//--- hu-05.h
69+
import "hu-03.h";
70+
import "hu-04.h";
71+
import "hu-01.h";
72+
73+
struct B {
74+
virtual ~B() = default;
75+
76+
virtual void f() {
77+
HT<long>();
78+
}
79+
};
80+
81+
//--- main.cpp
82+
import "hu-02.h";
83+
import "hu-05.h";
84+
import "hu-03.h";
85+
86+
int main() {
87+
f();
88+
C();
89+
B();
90+
}

0 commit comments

Comments
 (0)