Skip to content

Commit eac633d

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

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

clang/test/Modules/pr120277-2.cpp

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

0 commit comments

Comments
 (0)