forked from OSchip/llvm-project
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:
parent
f05c0958e2
commit
0cf82f6ad0
|
@ -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(),
|
||||
|
|
|
@ -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() { } };
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue