Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / PR42665.cpp
blob99e180171a3e645af3684572d51a5b31c4f173cb
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
4 // Minimal reproducer for PR42665.
5 // expected-no-diagnostics
7 struct Foo {
8 Foo() = default;
9 virtual ~Foo() = default;
12 template <typename Deleter>
13 struct Pair {
14 Foo first;
15 Deleter second;
18 template <typename Deleter>
19 Pair(Foo, Deleter) -> Pair<Deleter>;
21 template <typename T>
22 void deleter(T& t) { t.~T(); }
24 auto make_pair() {
25 return Pair{ Foo(), deleter<Foo> };
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.