diff options
| author | David Blaikie <dblaikie@gmail.com> | 2014-05-09 22:02:28 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2014-05-09 22:02:28 +0000 |
| commit | 04e2e665cb1cd7664b9b10427f8b29bd97523caf (patch) | |
| tree | 6edc20a9b7904effc86c9b13ea499a87a9bdc26b | |
| parent | d0eda92845ffb48ba71ff449c8917337f7c68476 (diff) | |
| download | bcm5719-llvm-04e2e665cb1cd7664b9b10427f8b29bd97523caf.tar.gz bcm5719-llvm-04e2e665cb1cd7664b9b10427f8b29bd97523caf.zip | |
Don't emit -Wnon-virtual-dtor on final classes, since it's not a problem there.
The base class is the culprit/risk here - a sealed/final derived class
with virtual functions and a non-virtual dtor can't accidentally be
polymorphically destroyed (if the base class's dtor is protected - which
also suppresses this warning).
llvm-svn: 208449
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 3 | ||||
| -rw-r--r-- | clang/test/SemaCXX/destructor.cpp | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 54a332aa99e..217588a9c09 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -4413,7 +4413,8 @@ void Sema::CheckCompletedCXXClass(CXXRecordDecl *Record) { // Warn if the class has virtual methods but non-virtual public destructor. if (Record->isPolymorphic() && !Record->isDependentType()) { CXXDestructorDecl *dtor = Record->getDestructor(); - if (!dtor || (!dtor->isVirtual() && dtor->getAccess() == AS_public)) + if ((!dtor || (!dtor->isVirtual() && dtor->getAccess() == AS_public)) && + !Record->hasAttr<FinalAttr>()) Diag(dtor ? dtor->getLocation() : Record->getLocation(), diag::warn_non_virtual_dtor) << Context.getRecordType(Record); } diff --git a/clang/test/SemaCXX/destructor.cpp b/clang/test/SemaCXX/destructor.cpp index 7642228c6f8..d0a0731c11e 100644 --- a/clang/test/SemaCXX/destructor.cpp +++ b/clang/test/SemaCXX/destructor.cpp @@ -195,7 +195,7 @@ struct B { // expected-warning {{has virtual functions but non-virtual destructo struct D: B {}; // expected-warning {{has virtual functions but non-virtual destructor}} -struct F final: B {}; // expected-warning {{has virtual functions but non-virtual destructor}} +struct F final : B {}; struct VB { virtual void foo(); |

