]> granicus.if.org Git - clang/commitdiff
Teach the virtual-functions-without-virtual-destructor warning to only
authorDouglas Gregor <dgregor@apple.com>
Sat, 19 Feb 2011 19:14:36 +0000 (19:14 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sat, 19 Feb 2011 19:14:36 +0000 (19:14 +0000)
warn about polymorphic classes (which have virtual functions) rather
than dynamic classes (which are polymorphic or have virtual bases).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126036 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/destructor.cpp

index d88d88c37ca1420f0836abb4fac9d91a2522b8c1..2e6c4c8ace6e7f51b82a42763cf5940464fea02e 100644 (file)
@@ -2767,7 +2767,7 @@ void Sema::CheckCompletedCXXClass(CXXRecordDecl *Record) {
   }
 
   // Warn if the class has virtual methods but non-virtual public destructor.
-  if (Record->isDynamicClass() && !Record->isDependentType()) {
+  if (Record->isPolymorphic() && !Record->isDependentType()) {
     CXXDestructorDecl *dtor = Record->getDestructor();
     if (!dtor || (!dtor->isVirtual() && dtor->getAccess() == AS_public))
       Diag(dtor ? dtor->getLocation() : Record->getLocation(),
index ec437f7101e47b53c09ddec48552018132297feb..14a4fb891cd3b2e145b9d937512654658892bbae 100644 (file)
@@ -172,3 +172,8 @@ template<class T> class TS2 { // expected-warning {{'nonvirtualdtor::TS2<int>' h
 
 TS2<int> foo; // expected-note {{instantiation}}
 }
+
+namespace PR9238 {
+  class B { public: ~B(); };
+  class C : virtual B { public: ~C() { } };
+}