[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / defaulted-private-dtor.cpp
blobe6f955501a3071ed5b9b2a46fc89d982e3d949d1
1 // RUN: %clang_cc1 -verify -std=c++11 %s -fcxx-exceptions
3 class BadDtor {
4 // A private, but nonetheless trivial, destructor.
5 ~BadDtor() = default; // expected-note 9{{here}}
6 friend class K;
7 };
8 void f() {
9 BadDtor *p = new BadDtor[3]; // expected-error {{private destructor}}
10 delete [] p; // expected-error {{private destructor}}
11 const BadDtor &dd2 = BadDtor(); // expected-error {{private destructor}}
12 BadDtor dd; // expected-error {{private destructor}}
13 throw dd; // expected-error {{private destructor}}
15 struct V {
16 V();
17 BadDtor bd; // expected-note {{inaccessible destructor}}
19 V v; // expected-error {{deleted function}}
20 struct W : BadDtor { // expected-note {{inaccessible destructor}}
21 W();
23 W w; // expected-error {{deleted function}}
24 struct X : BadDtor { // expected-error {{private destructor}}
25 ~X() {}
27 struct Y {
28 BadDtor dd; // expected-error {{private destructor}}
29 ~Y() {}
31 struct Z : virtual BadDtor { // expected-error {{private destructor}}
32 ~Z() {}
34 BadDtor dd; // expected-error {{private destructor}}
36 class K : BadDtor {
37 void f() {
38 BadDtor *p = new BadDtor[3];
39 delete [] p;
40 const BadDtor &dd2 = BadDtor();
41 BadDtor dd;
42 throw dd;
45 BadDtor x;
46 goto dont_call_dtor;
48 dont_call_dtor:
51 struct Z : virtual BadDtor {
52 ~Z() {}
54 BadDtor dd;
55 ~K();