Disable -Wtautological-compare in template instantiations.

llvm-svn: 193888
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 772fee3..733bd0f 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4779,6 +4779,10 @@
 }
 
 static void CheckTrivialUnsignedComparison(Sema &S, BinaryOperator *E) {
+  // Disable warning in template instantiations.
+  if (!S.ActiveTemplateInstantiations.empty())
+    return;
+
   BinaryOperatorKind op = E->getOpcode();
   if (E->isValueDependent())
     return;
diff --git a/clang/test/SemaCXX/compare.cpp b/clang/test/SemaCXX/compare.cpp
index 22f2565..563a152 100644
--- a/clang/test/SemaCXX/compare.cpp
+++ b/clang/test/SemaCXX/compare.cpp
@@ -380,4 +380,23 @@
     less_than_max<long>(num);
     less_than_max<short>(num);
   }
+
+  template<typename T>
+  inline bool less_than_zero(T num, T value) {
+    return num < 0;  // no warning
+  }
+
+  template<typename T>
+  inline bool less_than_zero(unsigned num) {
+    // This should trigger one warning on the template pattern, and not a
+    // warning per specialization.
+    return num < 0;  // expected-warning{{comparison of unsigned expression < 0 is always false}}
+  }
+
+  void test11(unsigned num) {
+    less_than_zero(num, num);
+    less_than_zero<int>(num);
+    less_than_zero<long>(num);
+    less_than_zero<short>(num);
+  }
 }