Don't warn for -Wnon-virtual-dtor for dependent classes.

llvm-svn: 124735
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index c6ffcc7..b4c375d 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -2771,7 +2771,7 @@
   }
 
   // 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/clang/test/SemaCXX/destructor.cpp b/clang/test/SemaCXX/destructor.cpp
index ce01b3a..ec437f7 100644
--- a/clang/test/SemaCXX/destructor.cpp
+++ b/clang/test/SemaCXX/destructor.cpp
@@ -159,4 +159,16 @@
 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}}
 }