Fix PR10168: don't warn for unused non-dependent variables in both the template definition and each instantiation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133580 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/warn-unused-variables.cpp b/test/SemaCXX/warn-unused-variables.cpp
index 81f22a7..5ba1f2a 100644
--- a/test/SemaCXX/warn-unused-variables.cpp
+++ b/test/SemaCXX/warn-unused-variables.cpp
@@ -54,3 +54,29 @@
   static int y = 0; // expected-warning{{unused variable 'y'}}
 #pragma unused(x)
 }
+
+// PR10168
+namespace PR10168 {
+  // We expect a warning in the definition only for non-dependent variables, and
+  // a warning in the instantiation only for dependent variables.
+  template<typename T>
+  struct S {
+    void f() {
+      int a; // expected-warning {{unused variable 'a'}}
+      T b; // expected-warning 2{{unused variable 'b'}}
+    }
+  };
+
+  template<typename T>
+  void f() {
+    int a; // expected-warning {{unused variable 'a'}}
+    T b; // expected-warning 2{{unused variable 'b'}}
+  }
+
+  void g() {
+    S<int>().f(); // expected-note {{here}}
+    S<char>().f(); // expected-note {{here}}
+    f<int>(); // expected-note {{here}}
+    f<char>(); // expected-note {{here}}
+  }
+}