summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/destructor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/destructor.cpp')
-rw-r--r--test/SemaCXX/destructor.cpp70
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() { } };
+}
OpenPOWER on IntegriCloud