diff options
author | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
---|---|---|
committer | Zancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au> | 2012-09-24 09:58:17 +1000 |
commit | 222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch) | |
tree | 7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/SemaCXX/defaulted-private-dtor.cpp | |
parent | 3d206f03985b50beacae843d880bccdc91a9f424 (diff) |
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/SemaCXX/defaulted-private-dtor.cpp')
-rw-r--r-- | clang/test/SemaCXX/defaulted-private-dtor.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/defaulted-private-dtor.cpp b/clang/test/SemaCXX/defaulted-private-dtor.cpp new file mode 100644 index 0000000..e6f9555 --- /dev/null +++ b/clang/test/SemaCXX/defaulted-private-dtor.cpp @@ -0,0 +1,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(); +}; |