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