convert_ctor.pass.cpp revision bc8d3f97eb5c958007f2713238472e0c1c8fe02c
1//===----------------------------------------------------------------------===//
2//
3// ��������������������The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <memory>
11
12// default_delete
13
14#include <memory>
15#include <cassert>
16
17struct A
18{
19    static int count;
20    A() {++count;}
21    A(const A&) {++count;}
22    virtual ~A() {--count;}
23};
24
25int A::count = 0;
26
27struct B
28    : public A
29{
30    static int count;
31    B() {++count;}
32    B(const B&) {++count;}
33    virtual ~B() {--count;}
34};
35
36int B::count = 0;
37
38int main()
39{
40    std::default_delete<B> d2;
41    std::default_delete<A> d1 = d2;
42    A* p = new B;
43    assert(A::count == 1);
44    assert(B::count == 1);
45    d1(p);
46    assert(A::count == 0);
47    assert(B::count == 0);
48}
49