diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-02-19 19:14:36 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-02-19 19:14:36 +0000 |
commit | f4b793ceb60418b64d3593ba3c8240e3594bff8f (patch) | |
tree | bbaab5913f4b9532a2ff10bdced448f6ae433666 | |
parent | 5f39f706afeb4d4a6f246db1e8cd2da0fb5b7f37 (diff) |
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
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/destructor.cpp | 5 |
2 files changed, 6 insertions, 1 deletions
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 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() { } }; +} |