[cfe-commits] [PATCH] Disable -Wtautological-compare in template instantiations.
Richard Trieu
rtrieu at google.com
Mon Nov 19 09:42:41 PST 2012
http://llvm-reviews.chandlerc.com/D128
Files:
test/SemaCXX/compare.cpp
lib/Sema/SemaChecking.cpp
Index: test/SemaCXX/compare.cpp
===================================================================
--- test/SemaCXX/compare.cpp
+++ test/SemaCXX/compare.cpp
@@ -348,3 +348,16 @@
(void)((E)x == 1);
(void)((E)x == -1);
}
+
+template <typename T>
+void template9 (T t, unsigned u) {
+ (void)(t >= 0);
+ (void)(u >= 0); // expected-warning{{true}}
+
+ (void)(t != 0x100000000);
+ (void)(u != 0x100000000); // expected-warning{{true}}
+}
+
+void test9() {
+ template9<unsigned>(1,1);
+}
Index: lib/Sema/SemaChecking.cpp
===================================================================
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -4309,6 +4309,9 @@
if (E->isValueDependent())
return;
+ if (!S.ActiveTemplateInstantiations.empty())
+ return;
+
if (op == BO_LT && IsZero(S, E->getRHS())) {
S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_true_comparison)
<< "< 0" << "false" << HasEnumType(E->getLHS())
@@ -4336,6 +4339,9 @@
if (Value == 0)
return;
+ if (!S.ActiveTemplateInstantiations.empty())
+ return;
+
BinaryOperatorKind op = E->getOpcode();
QualType OtherT = Other->getType();
QualType ConstantT = Constant->getType();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128.1.patch
Type: text/x-patch
Size: 1215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121119/dc0abc88/attachment.bin>
More information about the cfe-commits
mailing list