2012-02-18 12:13:32 +08:00
|
|
|
// RUN: %clang_cc1 -verify -std=c++11 %s -fcxx-exceptions
|
|
|
|
|
|
|
|
class BadDtor {
|
|
|
|
// A private, but nonetheless trivial, destructor.
|
2012-02-26 15:51:39 +08:00
|
|
|
~BadDtor() = default; // expected-note 9{{here}}
|
2012-02-18 12:13:32 +08:00
|
|
|
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}}
|
|
|
|
}
|
2012-03-31 04:53:28 +08:00
|
|
|
struct V {
|
2012-02-25 15:33:38 +08:00
|
|
|
V();
|
2012-03-31 04:53:28 +08:00
|
|
|
BadDtor bd; // expected-note {{inaccessible destructor}}
|
2012-02-25 15:33:38 +08:00
|
|
|
};
|
2012-02-26 15:51:39 +08:00
|
|
|
V v; // expected-error {{deleted function}}
|
2012-03-31 04:53:28 +08:00
|
|
|
struct W : BadDtor { // expected-note {{inaccessible destructor}}
|
2012-02-25 15:33:38 +08:00
|
|
|
W();
|
|
|
|
};
|
2012-02-26 15:51:39 +08:00
|
|
|
W w; // expected-error {{deleted function}}
|
2012-02-18 12:13:32 +08:00
|
|
|
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();
|
|
|
|
};
|