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).

llvm-svn: 126036
This commit is contained in:
Douglas Gregor 2011-02-19 19:14:36 +00:00
parent f05c0958e2
commit 0cf82f6ad0
2 changed files with 6 additions and 1 deletions

View 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(),

View 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() { } };
}