Skip to content

Commit 59cbe2f

Browse files
authored
[C++20][Modules][Serialization] Add an additional test case for #120277. (#126349)
4b35dd5 was shipped to address #120277 . It was thought to be a regression in 19.x according to this comment: #120277 (comment) This is a test case that fails even in 17.x but nevertheless is also fixed by: 4b35dd5
1 parent 7c60725 commit 59cbe2f

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

clang/test/Modules/pr120277-2.cpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: split-file %s %t
4+
5+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-01.h \
6+
// RUN: -o %t/hu-01.pcm
7+
8+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-02.h \
9+
// RUN: -Wno-experimental-header-units -fmodule-file=%t/hu-01.pcm -o %t/hu-02.pcm
10+
11+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-03.h \
12+
// RUN: -Wno-experimental-header-units \
13+
// RUN: -fmodule-file=%t/hu-01.pcm -o %t/hu-03.pcm
14+
15+
// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/hu-04.h \
16+
// RUN: -Wno-experimental-header-units -fmodule-file=%t/hu-02.pcm \
17+
// RUN: -fmodule-file=%t/hu-03.pcm -o %t/hu-04.pcm
18+
19+
// RUN: %clang_cc1 -std=c++20 -emit-obj %t/main.cpp \
20+
// RUN: -Wno-experimental-header-units -fmodule-file=%t/hu-04.pcm
21+
//--- hu-01.h
22+
template <typename T>
23+
struct A {
24+
~A() { f(); }
25+
auto f() const { return 0; }
26+
};
27+
28+
template <typename T>
29+
struct B {
30+
int g() const { return a.f(); }
31+
A<T> a;
32+
};
33+
34+
//--- hu-02.h
35+
import "hu-01.h";
36+
37+
template <typename = void>
38+
struct C {
39+
void h() {
40+
B<int>().g();
41+
}
42+
};
43+
44+
template struct A<double>;
45+
46+
//--- hu-03.h
47+
import "hu-01.h";
48+
49+
inline B<int> b() {
50+
return {};
51+
}
52+
53+
//--- hu-04.h
54+
import "hu-02.h";
55+
import "hu-03.h";
56+
57+
inline void f4() {
58+
C{}.h();
59+
}
60+
61+
//--- main.cpp
62+
import "hu-04.h";
63+
64+
int main() {
65+
f4();
66+
}

0 commit comments

Comments
 (0)