diff options
Diffstat (limited to 'test/SemaCXX/virtual-base-used.cpp')
-rw-r--r-- | test/SemaCXX/virtual-base-used.cpp | 189 |
1 files changed, 158 insertions, 31 deletions
diff --git a/test/SemaCXX/virtual-base-used.cpp b/test/SemaCXX/virtual-base-used.cpp index c46cf5a8c9ef7..f0dcc969e8da0 100644 --- a/test/SemaCXX/virtual-base-used.cpp +++ b/test/SemaCXX/virtual-base-used.cpp @@ -1,89 +1,216 @@ // RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s +// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -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 %s +// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++11 %s // PR7800 // The Microsoft ABI doesn't have the concept of key functions, so we have different // expectations about when functions are first required for that case. +class NoDestroy { ~NoDestroy(); }; +#if __cplusplus <= 199711L +// expected-note@-2 3 {{declared private here}} #ifdef MSABI -// expected-note@+2 3 {{declared private here}} +// expected-note@-4 3 {{declared private here}} #endif -class NoDestroy { ~NoDestroy(); }; // expected-note 3 {{declared private here}} +#endif + struct A { virtual ~A(); +#if __cplusplus >= 201103L + // expected-note@-2 3 {{overridden virtual function is here}} +#endif }; +struct B : public virtual A { +#if __cplusplus >= 201103L +// expected-error@-2 {{deleted function '~B' cannot override a non-deleted function}} +// expected-note@-3 {{overridden virtual function is here}} +#endif + + NoDestroy x; +#if __cplusplus <= 199711L + // expected-error@-2 {{field of type 'NoDestroy' has private destructor}} #ifdef MSABI -// expected-error@+3 {{field of type 'NoDestroy' has private destructor}} + // expected-error@-4 {{field of type 'NoDestroy' has private destructor}} #endif -struct B : public virtual A { - NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}} -}; +#else + // expected-note@-7 {{destructor of 'B' is implicitly deleted because field 'x' has an inaccessible destructor}} #ifdef MSABI -// expected-note@+3 {{implicit default constructor for 'B' first required here}} -// expected-note@+2 {{implicit destructor for 'B' first required here}} + // expected-note@-9 {{default constructor of 'B' is implicitly deleted because field 'x' has an inaccessible destructor}} +#endif #endif +}; + struct D : public virtual B { +#if __cplusplus <= 199711L +#ifdef MSABI +// expected-note@-3 {{implicit default constructor for 'B' first required here}} +// expected-note@-4 {{implicit destructor for 'B' first required here}} +#endif +#else +#ifdef MSABI +// expected-note@-8 {{default constructor of 'D' is implicitly deleted because base class 'B' has a deleted default constructor}} +#endif +#endif virtual void foo(); ~D(); +#if __cplusplus >= 201103L + //expected-error@-2 {{non-deleted function '~D' cannot override a deleted function}} +#endif }; + #ifdef MSABI -D d; // expected-note {{implicit default constructor for 'D' first required here}} +D d; +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit default constructor for 'D' first required here}} #else -void D::foo() { // expected-note {{implicit destructor for 'B' first required here}} +// expected-error@-4 {{call to implicitly-deleted default constructor of 'D'}} +#endif +#else +void D::foo() { +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'B' first required here}} +#endif } #endif +struct E : public virtual A { +#if __cplusplus >= 201103L +// expected-error@-2 {{deleted function '~E' cannot override a non-deleted function}} +// expected-note@-3 {{overridden virtual function is here}} +#endif + + NoDestroy x; +#if __cplusplus <= 199711L + // expected-error@-2 {{field of type 'NoDestroy' has private destructor}} #ifdef MSABI -// expected-error@+3 {{field of type 'NoDestroy' has private destructor}} + // expected-error@-4 {{field of type 'NoDestroy' has private destructor}} #endif -struct E : public virtual A { - NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}} -}; +#else + // expected-note@-7 {{destructor of 'E' is implicitly deleted because field 'x' has an inaccessible destructor}} #ifdef MSABI -// expected-note@+2 {{implicit default constructor for 'E' first required here}} + // expected-note@-9 {{default constructor of 'E' is implicitly deleted because field 'x' has an inaccessible destructor}} +#endif #endif -struct F : public E { // expected-note {{implicit destructor for 'E' first required here}} }; + +struct F : public E { +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'E' first required here}} #ifdef MSABI -// expected-note@+2 {{implicit default constructor for 'F' first required here}} +// expected-note@-4 {{implicit default constructor for 'E' first required here}} +#endif +#else +// expected-error@-7 {{non-deleted function '~F' cannot override a deleted function}} +// expected-note@-8 {{while declaring the implicit destructor for 'F'}} +// expected-note@-9 {{overridden virtual function is here}} +#ifdef MSABI +// expected-note@-11 {{default constructor of 'F' is implicitly deleted because base class 'E' has a deleted default constructor}} +#endif #endif +}; + + struct G : public virtual F { +#ifdef MSABI +#if __cplusplus <= 199711L +// expected-note@-3 {{implicit default constructor for 'F' first required here}} +#else +// expected-note@-5 {{default constructor of 'G' is implicitly deleted because base class 'F' has a deleted default constructor}} +#endif +#endif + virtual void foo(); ~G(); +#if __cplusplus >= 201103L + //expected-error@-2 {{non-deleted function '~G' cannot override a deleted function}} +#endif }; + #ifdef MSABI -G g; // expected-note {{implicit default constructor for 'G' first required here}} +G g; +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit default constructor for 'G' first required here}} +#else +// expected-error@-4 {{call to implicitly-deleted default constructor of 'G'}} +#endif #else -void G::foo() { // expected-note {{implicit destructor for 'F' first required here}} +void G::foo() { +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'F' first required here}} +#endif } #endif +struct H : public virtual A { +#if __cplusplus >= 201103L +// expected-error@-2 {{deleted function '~H' cannot override a non-deleted function}} +// expected-note@-3 {{overridden virtual function is here}} +#else #ifdef MSABI -// expected-note@+3 {{'H' declared here}} -// expected-error@+3 {{field of type 'NoDestroy' has private destructor}} +// expected-note@-6 {{'H' declared here}} #endif -struct H : public virtual A { - NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}} -}; +#endif + + NoDestroy x; +#if __cplusplus <= 199711L + // expected-error@-2 {{field of type 'NoDestroy' has private destructor}} #ifdef MSABI -// expected-error@+3 {{implicit default constructor for 'I' must explicitly initialize the base class 'H' which does not have a default constructor}} -// expected-note@+2 {{implicit destructor for 'H' first required here}} + // expected-error@-4 {{field of type 'NoDestroy' has private destructor}} +#endif +#else + // expected-note@-7 {{destructor of 'H' is implicitly deleted because field 'x' has an inaccessible destructor}} +#ifdef MSABI + // expected-note@-9 {{default constructor of 'H' is implicitly deleted because field 'x' has an inaccessible destructor}} +#endif #endif +}; + struct I : public virtual H { +#ifdef MSABI +#if __cplusplus <= 199711L +// expected-error@-3 {{implicit default constructor for 'I' must explicitly initialize the base class 'H' which does not have a default constructor}} +// expected-note@-4 {{implicit destructor for 'H' first required here}} +#else +// expected-note@-6 {{default constructor of 'I' is implicitly deleted because base class 'H' has a deleted default constructor}} +#endif +#endif + ~I(); +#if __cplusplus >= 201103L +// expected-error@-2 {{non-deleted function '~I' cannot override a deleted function}} +#endif }; + +struct J : public I { #ifdef MSABI -// expected-note@+3 {{implicit default constructor for 'H' first required here}} -// expected-note@+2 {{implicit default constructor for 'I' first required here}} +#if __cplusplus <= 199711L +// expected-note@-3 {{implicit default constructor for 'H' first required here}} +// expected-note@-4 {{implicit default constructor for 'I' first required here}} +#else +// expected-note@-6 {{default constructor of 'J' is implicitly deleted because base class 'I' has a deleted default constructor}} #endif -struct J : public I { +#endif + virtual void foo(); ~J(); }; + #ifdef MSABI -J j; // expected-note {{implicit default constructor for 'J' first required here}} +J j; +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit default constructor for 'J' first required here}} #else -void J::foo() { // expected-note {{implicit destructor for 'H' first required here}} +// expected-error@-4 {{call to implicitly-deleted default constructor of 'J'}} +#endif + +#else +void J::foo() { +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'H' first required here}} +#endif } #endif |