From: Douglas Gregor Date: Sat, 19 Feb 2011 19:14:36 +0000 (+0000) Subject: Teach the virtual-functions-without-virtual-destructor warning to only X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f4b793ceb60418b64d3593ba3c8240e3594bff8f;p=clang Teach the virtual-functions-without-virtual-destructor warning to only 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 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index d88d88c37c..2e6c4c8ace 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -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(), diff --git a/test/SemaCXX/destructor.cpp b/test/SemaCXX/destructor.cpp index ec437f7101..14a4fb891c 100644 --- a/test/SemaCXX/destructor.cpp +++ b/test/SemaCXX/destructor.cpp @@ -172,3 +172,8 @@ template class TS2 { // expected-warning {{'nonvirtualdtor::TS2' h TS2 foo; // expected-note {{instantiation}} } + +namespace PR9238 { + class B { public: ~B(); }; + class C : virtual B { public: ~C() { } }; +}