diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-02 18:47:41 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-02 18:47:41 +0000 |
commit | 668fdd8578c85aa2692ffdeb7614acabf1aaab25 (patch) | |
tree | ad6a1c5d5e84a92f433f4971290fc4e91031fa33 | |
parent | eef63e0997e0f6d6436736ea919b851cfe34955a (diff) |
Don't warn for -Wnon-virtual-dtor for dependent classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124735 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/destructor.cpp | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index c6ffcc759e..b4c375d638 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -2771,7 +2771,7 @@ void Sema::CheckCompletedCXXClass(CXXRecordDecl *Record) { } // Warn if the class has virtual methods but non-virtual public destructor. - if (Record->isDynamicClass()) { + if (Record->isDynamicClass() && !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 ce01b3acc5..ec437f7101 100644 --- a/test/SemaCXX/destructor.cpp +++ b/test/SemaCXX/destructor.cpp @@ -159,4 +159,16 @@ struct S7 { protected: ~S7(); }; + +template<class T> class TS : public B { + virtual void m(); +}; + +TS<int> baz; + +template<class T> class TS2 { // expected-warning {{'nonvirtualdtor::TS2<int>' has virtual functions but non-virtual destructor}} + virtual void m(); +}; + +TS2<int> foo; // expected-note {{instantiation}} } |