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 }; 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}} 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}} 25 ~X() {} 26 }; 27 struct Y { 28 BadDtor dd; // expected-error {{private destructor}} 29 ~Y() {} 30 }; 31 struct Z : virtual BadDtor { // expected-error {{private destructor}} 32 ~Z() {} 33 }; 34 BadDtor dd; // expected-error {{private destructor}} 35 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; 43 44 { 45 BadDtor x; 46 goto dont_call_dtor; 47 } 48 dont_call_dtor: 49 ; 50 } 51 struct Z : virtual BadDtor { 52 ~Z() {} 53 }; 54 BadDtor dd; 55 ~K(); 56 }; 57