| 1 |
// RUN: %clang_cc1 -std=c++17 -O0 %s -emit-llvm -o /dev/null -verify -triple %itanium_abi_triple |
| 2 |
// RUN: %clang_cc1 -std=c++17 -O0 %s -emit-llvm -o /dev/null -verify -triple %ms_abi_triple |
| 3 |
|
| 4 |
// Minimal reproducer for PR42665. |
| 5 |
// expected-no-diagnostics |
| 6 |
|
| 7 |
struct Foo { |
| 8 |
Foo() = default; |
| 9 |
virtual ~Foo() = default; |
| 10 |
}; |
| 11 |
|
| 12 |
template <typename Deleter> |
| 13 |
struct Pair { |
| 14 |
Foo first; |
| 15 |
Deleter second; |
| 16 |
}; |
| 17 |
|
| 18 |
template <typename Deleter> |
| 19 |
Pair(Foo, Deleter) -> Pair<Deleter>; |
| 20 |
|
| 21 |
template <typename T> |
| 22 |
void deleter(T& t) { t.~T(); } |
| 23 |
|
| 24 |
auto make_pair() { |
| 25 |
return Pair{ Foo(), deleter<Foo> }; |
| 26 |
} |
| 27 |
|
| 28 |
void foobar() { |
| 29 |
auto p = make_pair(); |
| 30 |
auto& f = p.first; |
| 31 |
auto& d = p.second; |
| 32 |
d(f); // Invoke virtual destructor of Foo through d. |
| 33 |
} // p's destructor is invoked. |
| 34 |
|