reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
// RUN: %clang_cc1 -std=c++17 -O0 %s -emit-llvm -o /dev/null -verify -triple %itanium_abi_triple
// RUN: %clang_cc1 -std=c++17 -O0 %s -emit-llvm -o /dev/null -verify -triple %ms_abi_triple

// Minimal reproducer for PR42665.
// expected-no-diagnostics

struct Foo {
  Foo() = default;
  virtual ~Foo() = default;
};

template <typename Deleter>
struct Pair {
  Foo first;
  Deleter second;
};

template <typename Deleter>
Pair(Foo, Deleter) -> Pair<Deleter>;

template <typename T>
void deleter(T& t) { t.~T(); }

auto make_pair() {
  return Pair{ Foo(), deleter<Foo> };
}

void foobar() {
  auto p = make_pair();
  auto& f = p.first;
  auto& d = p.second;
  d(f); // Invoke virtual destructor of Foo through d.
} // p's destructor is invoked.