diff options
author | dim <dim@FreeBSD.org> | 2011-02-20 13:06:31 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-02-20 13:06:31 +0000 |
commit | 39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df (patch) | |
tree | a9243275843fbeaa590afc07ee888e006b8d54ea /test/SemaCXX/destructor.cpp | |
parent | 69b4eca4a4255ba43baa5c1d9bbdec3ec17f479e (diff) | |
download | FreeBSD-src-39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df.zip FreeBSD-src-39fcc9a984e2820e4ea0fa2ac4abd17d9f3a31df.tar.gz |
Vendor import of clang trunk r126079:
http://llvm.org/svn/llvm-project/cfe/trunk@126079
Diffstat (limited to 'test/SemaCXX/destructor.cpp')
-rw-r--r-- | test/SemaCXX/destructor.cpp | 70 |
1 files changed, 64 insertions, 6 deletions
diff --git a/test/SemaCXX/destructor.cpp b/test/SemaCXX/destructor.cpp index cdcae2e..14a4fb8 100644 --- a/test/SemaCXX/destructor.cpp +++ b/test/SemaCXX/destructor.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wnon-virtual-dtor -verify %s class A { public: ~A(); @@ -67,7 +67,7 @@ struct Y { namespace PR6421 { class T; // expected-note{{forward declaration}} - class QGenericArgument + class QGenericArgument // expected-note{{declared here}} { template<typename U> void foo(T t) // expected-error{{variable has incomplete type}} @@ -76,7 +76,8 @@ namespace PR6421 { void disconnect() { T* t; - bob<QGenericArgument>(t); // expected-error{{undeclared identifier 'bob'}} + bob<QGenericArgument>(t); // expected-error{{undeclared identifier 'bob'}} \ + // expected-error{{does not refer to a value}} } }; } @@ -99,11 +100,11 @@ namespace test6 { T::deleteIt(p); // expected-error {{type 'int' cannot be used prior to '::'}} } - virtual ~A() {} // expected-note {{in instantiation of member function 'test6::A<int>::operator delete' requested here}} + virtual ~A() {} }; - class B : A<int> { B(); }; - B::B() {} // expected-note {{in instantiation of member function 'test6::A<int>::~A' requested here}} + class B : A<int> { B(); }; // expected-note {{in instantiation of member function 'test6::A<int>::operator delete' requested here}} + B::B() {} } // Make sure classes are marked invalid when they have invalid @@ -119,3 +120,60 @@ namespace test7 { b->~B(); } } + +namespace nonvirtualdtor { +struct S1 { // expected-warning {{has virtual functions but non-virtual destructor}} + virtual void m(); +}; + +struct S2 { + ~S2(); // expected-warning {{has virtual functions but non-virtual destructor}} + virtual void m(); +}; + +struct S3 : public S1 { // expected-warning {{has virtual functions but non-virtual destructor}} + virtual void m(); +}; + +struct S4 : public S2 { // expected-warning {{has virtual functions but non-virtual destructor}} + virtual void m(); +}; + +struct B { + virtual ~B(); + virtual void m(); +}; + +struct S5 : public B { + virtual void m(); +}; + +struct S6 { + virtual void m(); +private: + ~S6(); +}; + +struct S7 { + virtual void m(); +protected: + ~S7(); +}; + +template<class T> class TS : public B { + virtual void m(); +}; + +TS<int> baz; + +template<class T> class TS2 { // expected-warning {{'nonvirtualdtor::TS2<int>' has virtual functions but non-virtual destructor}} + virtual void m(); +}; + +TS2<int> foo; // expected-note {{instantiation}} +} + +namespace PR9238 { + class B { public: ~B(); }; + class C : virtual B { public: ~C() { } }; +} |