diff options
-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}} } |