diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-01-31 07:05:00 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-01-31 07:05:00 +0000 |
commit | def4e2a405a15eb8381ca305725285d27a4bab65 (patch) | |
tree | 55dde82193fcb662f66b337e7befdd1a8355b1ef /lib/Sema/SemaDeclCXX.cpp | |
parent | 36eb5e43bcdbe291da4df696755009ffd6a35ac2 (diff) |
Warn if the class has virtual methods but non-virtual destructor. Addresses rdar://8756445.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124582 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index c9c58b3e3a..89332eae0e 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -2769,6 +2769,14 @@ void Sema::CheckCompletedCXXClass(CXXRecordDecl *Record) { } } } + + // Warn if the class has virtual methods but non-virtual destructor. + if (Record->isDynamicClass()) { + CXXDestructorDecl *dtor = Record->getDestructor(); + if (!(dtor && dtor->isVirtual())) + Diag(dtor ? dtor->getLocation() : Record->getLocation(), + diag::warn_non_virtual_dtor) << Context.getRecordType(Record); + } } void Sema::ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc, |