diff options
author | Richard Trieu <rtrieu@google.com> | 2013-11-01 21:47:19 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2013-11-01 21:47:19 +0000 |
commit | 36594561aa663b9d65e73eadef42ee5bd9fe5d35 (patch) | |
tree | 0eb29fa14e9027eee584659b13f269ac5efbdf24 | |
parent | dd51d747bf8f5424496f7948c38f6ca42567f5c4 (diff) | |
download | bcm5719-llvm-36594561aa663b9d65e73eadef42ee5bd9fe5d35.tar.gz bcm5719-llvm-36594561aa663b9d65e73eadef42ee5bd9fe5d35.zip |
Disable -Wtautological-compare in template instantiations.
llvm-svn: 193888
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaCXX/compare.cpp | 19 |
2 files changed, 23 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 772fee32ceb..733bd0f9bbf 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -4779,6 +4779,10 @@ static bool HasEnumType(Expr *E) { } 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 22f2565882c..563a15251c3 100644 --- a/clang/test/SemaCXX/compare.cpp +++ b/clang/test/SemaCXX/compare.cpp @@ -380,4 +380,23 @@ namespace templates { 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); + } } |