defaulted-private-dtor.cpp
1.33 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// RUN: %clang_cc1 -verify -std=c++11 %s -fcxx-exceptions
class BadDtor {
// A private, but nonetheless trivial, destructor.
~BadDtor() = default; // expected-note 9{{here}}
friend class K;
};
void f() {
BadDtor *p = new BadDtor[3]; // expected-error {{private destructor}}
delete [] p; // expected-error {{private destructor}}
const BadDtor &dd2 = BadDtor(); // expected-error {{private destructor}}
BadDtor dd; // expected-error {{private destructor}}
throw dd; // expected-error {{private destructor}}
}
struct V {
V();
BadDtor bd; // expected-note {{inaccessible destructor}}
};
V v; // expected-error {{deleted function}}
struct W : BadDtor { // expected-note {{inaccessible destructor}}
W();
};
W w; // expected-error {{deleted function}}
struct X : BadDtor { // expected-error {{private destructor}}
~X() {}
};
struct Y {
BadDtor dd; // expected-error {{private destructor}}
~Y() {}
};
struct Z : virtual BadDtor { // expected-error {{private destructor}}
~Z() {}
};
BadDtor dd; // expected-error {{private destructor}}
class K : BadDtor {
void f() {
BadDtor *p = new BadDtor[3];
delete [] p;
const BadDtor &dd2 = BadDtor();
BadDtor dd;
throw dd;
{
BadDtor x;
goto dont_call_dtor;
}
dont_call_dtor:
;
}
struct Z : virtual BadDtor {
~Z() {}
};
BadDtor dd;
~K();
};