1 // RUN: %clang_cc1 -verify -std=c++11 %s -fcxx-exceptions 2 3 class BadDtor { 4 // A private, but nonetheless trivial, destructor. 5 ~BadDtor() = default; // expected-note 9{{here}} 6 friend class K; 7 }; f()8void 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}} 14 } 15 struct V { 16 V(); 17 BadDtor bd; // expected-note {{inaccessible destructor}} 18 }; 19 V v; // expected-error {{deleted function}} 20 struct W : BadDtor { // expected-note {{inaccessible destructor}} 21 W(); 22 }; 23 W w; // expected-error {{deleted function}} 24 struct X : BadDtor { // expected-error {{private destructor}} ~XX25 ~X() {} 26 }; 27 struct Y { 28 BadDtor dd; // expected-error {{private destructor}} ~YY29 ~Y() {} 30 }; 31 struct Z : virtual BadDtor { // expected-error {{private destructor}} ~ZZ32 ~Z() {} 33 }; 34 BadDtor dd; // expected-error {{private destructor}} 35 36 class K : BadDtor { f()37 void f() { 38 BadDtor *p = new BadDtor[3]; 39 delete [] p; 40 const BadDtor &dd2 = BadDtor(); 41 BadDtor dd; 42 throw dd; 43 44 { 45 BadDtor x; 46 goto dont_call_dtor; 47 } 48 dont_call_dtor: 49 ; 50 } 51 struct Z : virtual BadDtor { ~ZK::Z52 ~Z() {} 53 }; 54 BadDtor dd; 55 ~K(); 56 }; 57