diff options
Diffstat (limited to 'test/CXX/special/class.dtor/p9.cpp')
| -rw-r--r-- | test/CXX/special/class.dtor/p9.cpp | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/test/CXX/special/class.dtor/p9.cpp b/test/CXX/special/class.dtor/p9.cpp index 42a4236a4a079..e812491fbb4b3 100644 --- a/test/CXX/special/class.dtor/p9.cpp +++ b/test/CXX/special/class.dtor/p9.cpp @@ -1,7 +1,9 @@ -// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s -// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s +// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++11 %s -typedef typeof(sizeof(int)) size_t; +typedef __typeof(sizeof(int)) size_t; // PR7803 namespace test0 { @@ -29,13 +31,13 @@ namespace test0 { namespace test1 { class A { public: - static void operator delete(void *p) {}; // expected-note {{member 'operator delete' declared here}} + static void operator delete(void *p) {}; virtual ~A(); }; class B : protected A { public: - static void operator delete(void *, size_t) {}; // expected-note {{member 'operator delete' declared here}} + static void operator delete(void *, size_t) {}; ~B(); }; @@ -47,7 +49,20 @@ namespace test1 { ~C(); }; - C::~C() {} // expected-error {{multiple suitable 'operator delete' functions in 'C'}} + // We assume that the intent is to treat C::operator delete(void*, size_t) as + // /not/ being a usual deallocation function, as it would be if it were + // declared with in C directly. + C::~C() {} + + struct D { + void operator delete(void*); // expected-note {{member 'operator delete' declared here}} + void operator delete(void*, ...); // expected-note {{member 'operator delete' declared here}} + virtual ~D(); + }; + // FIXME: The standard doesn't say this is ill-formed, but presumably either + // it should be or the variadic operator delete should not be a usual + // deallocation function. + D::~D() {} // expected-error {{multiple suitable 'operator delete' functions in 'D'}} } // ...at the point of definition of a virtual destructor... @@ -63,6 +78,7 @@ namespace test2 { }; B::~B() {} // expected-error {{no suitable member 'operator delete' in 'B'}} +#if __cplusplus < 201103L struct CBase { virtual ~CBase(); }; struct C : CBase { // expected-error {{no suitable member 'operator delete' in 'C'}} static void operator delete(void*, const int &); // expected-note {{declared here}} @@ -70,6 +86,15 @@ namespace test2 { void test() { C c; // expected-note {{first required here}} } +#else + struct CBase { virtual ~CBase(); }; // expected-note {{overridden virtual function is here}} + struct C : CBase { // expected-error {{deleted function '~C' cannot override a non-deleted function}} expected-note 2{{requires an unambiguous, accessible 'operator delete'}} + static void operator delete(void*, const int &); + }; + void test() { + C c; // expected-error {{attempt to use a deleted function}} + } +#endif } // PR7346 |
