<div dir="ltr">Nice fix! It catches a lot of new cases on our codebase, all technically correct so far.<br><div><br></div><div>A couple of issues though:</div><div>A) Rollout - until we've completely cleaned up, we need to disable -Wtautological-compare entirely, which is a valuable check. I imagine anyone else using -Werror is in the same boat.</div><div>What do you think about putting the new warnings behind a subcategory? (e.g. -Wtautological-compare-unsigned-zero, implied by -Wtautological-compare)</div><div>It's an ugly artifact of the history here, but allows this fix to be rolled out in a controlled way.</div><div><br></div><div>B) Enums (not new I guess). Typical case: if (enum < 0 || enum > MAX)</div><div>The warning strongly suggests that the enum < 0 check has no effect (for enums with nonnegative ranges).</div><div>Clang doesn't seem to optimize such checks out though, and they seem likely to catch bugs in some cases. Yes, only if there's UB elsewhere, but I assume not optimizing out these checks indicates a deliberate decision to stay somewhat compatible with a technically-incorrect mental model.</div><div>If this is the case, should we move these to a -Wtautological-compare-enum subcategory?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 8, 2017 at 12:14 AM, Roman Lebedev via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: lebedevri<br>
Date: Thu Sep  7 15:14:25 2017<br>
New Revision: 312750<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=312750&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=312750&view=rev</a><br>
Log:<br>
[Sema] -Wtautological-compare: handle comparison of unsigned with 0S.<br>
<br>
Summary:<br>
This is a first half(?) of a fix for the following bug:<br>
<a href="https://bugs.llvm.org/show_bug.cgi?id=34147" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_<wbr>bug.cgi?id=34147</a> (gcc -Wtype-limits)<br>
<br>
GCC's -Wtype-limits does warn on comparison of unsigned value<br>
with signed zero (as in, with 0), but clang only warns if the<br>
zero is unsigned (i.e. 0U).<br>
<br>
Also, be careful not to double-warn, or falsely warn on<br>
comparison of signed/fp variable and signed 0.<br>
<br>
Yes, all these testcases are needed.<br>
<br>
Testing: $ ninja check-clang-sema check-clang-semacxx<br>
Also, no new warnings for clang stage-2 build.<br>
<br>
Reviewers: rjmccall, rsmith, aaron.ballman<br>
<br>
Reviewed By: rjmccall<br>
<br>
Subscribers: cfe-commits<br>
<br>
Tags: #clang<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D37565" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D37565</a><br>
<br>
Modified:<br>
    cfe/trunk/docs/ReleaseNotes.<wbr>rst<br>
    cfe/trunk/lib/Sema/<wbr>SemaChecking.cpp<br>
    cfe/trunk/test/Sema/compare.c<br>
    cfe/trunk/test/Sema/outof-<wbr>range-constant-compare.c<br>
    cfe/trunk/test/SemaCXX/<wbr>compare.cpp<br>
<br>
Modified: cfe/trunk/docs/ReleaseNotes.<wbr>rst<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=312750&r1=312749&r2=312750&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/docs/<wbr>ReleaseNotes.rst?rev=312750&<wbr>r1=312749&r2=312750&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/docs/ReleaseNotes.<wbr>rst (original)<br>
+++ cfe/trunk/docs/ReleaseNotes.<wbr>rst Thu Sep  7 15:14:25 2017<br>
@@ -71,6 +71,13 @@ Improvements to Clang's diagnostics<br>
   errors/warnings, as the system frameworks might add a method with the same<br>
   selector which could make the message send to ``id`` ambiguous.<br>
<br>
+- ``-Wtautological-compare`` now warns when comparing an unsigned integer and 0<br>
+  regardless of whether the constant is signed or unsigned."<br>
+<br>
+- ``-Wtautological-compare`` now warns about comparing a signed integer and 0<br>
+  when the signed integer is coerced to an unsigned type for the comparison.<br>
+  ``-Wsign-compare`` was adjusted not to warn in this case.<br>
+<br>
 Non-comprehensive list of changes in this release<br>
 ------------------------------<wbr>-------------------<br>
<br>
<br>
Modified: cfe/trunk/lib/Sema/<wbr>SemaChecking.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=312750&r1=312749&r2=312750&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Sema/<wbr>SemaChecking.cpp?rev=312750&<wbr>r1=312749&r2=312750&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Sema/<wbr>SemaChecking.cpp (original)<br>
+++ cfe/trunk/lib/Sema/<wbr>SemaChecking.cpp Thu Sep  7 15:14:25 2017<br>
@@ -8567,32 +8567,51 @@ bool HasEnumType(Expr *E) {<br>
   return E->getType()->isEnumeralType()<wbr>;<br>
 }<br>
<br>
-void CheckTrivialUnsignedComparison<wbr>(Sema &S, BinaryOperator *E) {<br>
+bool isNonBooleanUnsignedValue(Expr *E) {<br>
+  // We are checking that the expression is not known to have boolean value,<br>
+  // is an integer type; and is either unsigned after implicit casts,<br>
+  // or was unsigned before implicit casts.<br>
+  return !E->isKnownToHaveBooleanValue(<wbr>) && E->getType()->isIntegerType() &&<br>
+         (!E->getType()-><wbr>isSignedIntegerType() ||<br>
+          !E->IgnoreParenImpCasts()-><wbr>getType()-><wbr>isSignedIntegerType());<br>
+}<br>
+<br>
+bool CheckTautologicalComparisonWit<wbr>hZero(Sema &S, BinaryOperator *E) {<br>
   // Disable warning in template instantiations.<br>
   if (S.inTemplateInstantiation())<br>
-    return;<br>
+    return false;<br>
+<br>
+  // bool values are handled by DiagnoseOutOfRangeComparison()<wbr>.<br>
<br>
   BinaryOperatorKind op = E->getOpcode();<br>
   if (E->isValueDependent())<br>
-    return;<br>
+    return false;<br>
<br>
-  if (op == BO_LT && IsZero(S, E->getRHS())) {<br>
+  Expr *LHS = E->getLHS();<br>
+  Expr *RHS = E->getRHS();<br>
+<br>
+  bool Match = true;<br>
+<br>
+  if (op == BO_LT && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {<br>
     S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_<wbr>true_comparison)<br>
-      << "< 0" << "false" << HasEnumType(E->getLHS())<br>
-      << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange();<br>
-  } else if (op == BO_GE && IsZero(S, E->getRHS())) {<br>
+      << "< 0" << "false" << HasEnumType(LHS)<br>
+      << LHS->getSourceRange() << RHS->getSourceRange();<br>
+  } else if (op == BO_GE && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {<br>
     S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_<wbr>true_comparison)<br>
-      << ">= 0" << "true" << HasEnumType(E->getLHS())<br>
-      << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange();<br>
-  } else if (op == BO_GT && IsZero(S, E->getLHS())) {<br>
+      << ">= 0" << "true" << HasEnumType(LHS)<br>
+      << LHS->getSourceRange() << RHS->getSourceRange();<br>
+  } else if (op == BO_GT && isNonBooleanUnsignedValue(RHS) && IsZero(S, LHS)) {<br>
     S.Diag(E->getOperatorLoc(), diag::warn_runsigned_always_<wbr>true_comparison)<br>
-      << "0 >" << "false" << HasEnumType(E->getRHS())<br>
-      << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange();<br>
-  } else if (op == BO_LE && IsZero(S, E->getLHS())) {<br>
+      << "0 >" << "false" << HasEnumType(RHS)<br>
+      << LHS->getSourceRange() << RHS->getSourceRange();<br>
+  } else if (op == BO_LE && isNonBooleanUnsignedValue(RHS) && IsZero(S, LHS)) {<br>
     S.Diag(E->getOperatorLoc(), diag::warn_runsigned_always_<wbr>true_comparison)<br>
-      << "0 <=" << "true" << HasEnumType(E->getRHS())<br>
-      << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange();<br>
-  }<br>
+      << "0 <=" << "true" << HasEnumType(RHS)<br>
+      << LHS->getSourceRange() << RHS->getSourceRange();<br>
+  } else<br>
+    Match = false;<br>
+<br>
+  return Match;<br>
 }<br>
<br>
 void DiagnoseOutOfRangeComparison(<wbr>Sema &S, BinaryOperator *E, Expr *Constant,<br>
@@ -8612,7 +8631,7 @@ void DiagnoseOutOfRangeComparison(<wbr>Sema &<br>
<br>
   bool OtherIsBooleanType = Other-><wbr>isKnownToHaveBooleanValue();<br>
<br>
-  // 0 values are handled later by CheckTrivialUnsignedComparison<wbr>().<br>
+  // 0 values are handled later by CheckTautologicalComparisonWit<wbr>hZero().<br>
   if ((Value == 0) && (!OtherIsBooleanType))<br>
     return;<br>
<br>
@@ -8849,16 +8868,22 @@ void AnalyzeComparison(Sema &S, BinaryOp<br>
         (IsRHSIntegralLiteral && IsLHSIntegralLiteral);<br>
   } else if (!T-><wbr>hasUnsignedIntegerRepresentati<wbr>on())<br>
       IsComparisonConstant = E->isIntegerConstantExpr(S.<wbr>Context);<br>
-<br>
+<br>
+  // We don't care about value-dependent expressions or expressions<br>
+  // whose result is a constant.<br>
+  if (IsComparisonConstant)<br>
+    return AnalyzeImpConvsInComparison(S, E);<br>
+<br>
+  // If this is a tautological comparison, suppress -Wsign-compare.<br>
+  if (<wbr>CheckTautologicalComparisonWit<wbr>hZero(S, E))<br>
+    return AnalyzeImpConvsInComparison(S, E);<br>
+<br>
   // We don't do anything special if this isn't an unsigned integral<br>
   // comparison:  we're only interested in integral comparisons, and<br>
   // signed comparisons only happen in cases we don't care to warn about.<br>
-  //<br>
-  // We also don't care about value-dependent expressions or expressions<br>
-  // whose result is a constant.<br>
-  if (!T-><wbr>hasUnsignedIntegerRepresentati<wbr>on() || IsComparisonConstant)<br>
+  if (!T-><wbr>hasUnsignedIntegerRepresentati<wbr>on())<br>
     return AnalyzeImpConvsInComparison(S, E);<br>
-<br>
+<br>
   // Check to see if one of the (unmodified) operands is of different<br>
   // signedness.<br>
   Expr *signedOperand, *unsignedOperand;<br>
@@ -8871,7 +8896,6 @@ void AnalyzeComparison(Sema &S, BinaryOp<br>
     signedOperand = RHS;<br>
     unsignedOperand = LHS;<br>
   } else {<br>
-    CheckTrivialUnsignedComparison<wbr>(S, E);<br>
     return AnalyzeImpConvsInComparison(S, E);<br>
   }<br>
<br>
@@ -8883,11 +8907,9 @@ void AnalyzeComparison(Sema &S, BinaryOp<br>
   AnalyzeImplicitConversions(S, LHS, E->getOperatorLoc());<br>
   AnalyzeImplicitConversions(S, RHS, E->getOperatorLoc());<br>
<br>
-  // If the signed range is non-negative, -Wsign-compare won't fire,<br>
-  // but we should still check for comparisons which are always true<br>
-  // or false.<br>
+  // If the signed range is non-negative, -Wsign-compare won't fire.<br>
   if (signedRange.NonNegative)<br>
-    return CheckTrivialUnsignedComparison<wbr>(S, E);<br>
+    return;<br>
<br>
   // For (in)equality comparisons, if the unsigned operand is a<br>
   // constant which cannot collide with a overflowed signed operand,<br>
<br>
Modified: cfe/trunk/test/Sema/compare.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/compare.c?rev=312750&r1=312749&r2=312750&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/Sema/<wbr>compare.c?rev=312750&r1=<wbr>312749&r2=312750&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Sema/compare.c (original)<br>
+++ cfe/trunk/test/Sema/compare.c Thu Sep  7 15:14:25 2017<br>
@@ -77,7 +77,7 @@ int ints(long a, unsigned long b) {<br>
          ((int) a == (unsigned int) B) +<br>
          ((short) a == (unsigned short) B) +<br>
          ((signed char) a == (unsigned char) B) +<br>
-         (a < (unsigned long) B) +  // expected-warning {{comparison of integers of different signs}}<br>
+         (a < (unsigned long) B) +  // expected-warning {{comparison of unsigned expression < 0 is always false}}<br>
          (a < (unsigned int) B) +<br>
          (a < (unsigned short) B) +<br>
          (a < (unsigned char) B) +<br>
@@ -85,8 +85,8 @@ int ints(long a, unsigned long b) {<br>
          ((int) a < B) +<br>
          ((short) a < B) +<br>
          ((signed char) a < B) +<br>
-         ((long) a < (unsigned long) B) +  // expected-warning {{comparison of integers of different signs}}<br>
-         ((int) a < (unsigned int) B) +  // expected-warning {{comparison of integers of different signs}}<br>
+         ((long) a < (unsigned long) B) +  // expected-warning {{comparison of unsigned expression < 0 is always false}}<br>
+         ((int) a < (unsigned int) B) +  // expected-warning {{comparison of unsigned expression < 0 is always false}}<br>
          ((short) a < (unsigned short) B) +<br>
          ((signed char) a < (unsigned char) B) +<br>
<br>
<br>
Modified: cfe/trunk/test/Sema/outof-<wbr>range-constant-compare.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/outof-range-constant-compare.c?rev=312750&r1=312749&r2=312750&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/Sema/<wbr>outof-range-constant-compare.<wbr>c?rev=312750&r1=312749&r2=<wbr>312750&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Sema/outof-<wbr>range-constant-compare.c (original)<br>
+++ cfe/trunk/test/Sema/outof-<wbr>range-constant-compare.c Thu Sep  7 15:14:25 2017<br>
@@ -6,6 +6,59 @@ int value(void);<br>
 int main()<br>
 {<br>
     int a = value();<br>
+<br>
+    if (a == 0x0000000000000000L)<br>
+        return 0;<br>
+    if (a != 0x0000000000000000L)<br>
+        return 0;<br>
+    if (a < 0x0000000000000000L)<br>
+        return 0;<br>
+    if (a <= 0x0000000000000000L)<br>
+        return 0;<br>
+    if (a > 0x0000000000000000L)<br>
+        return 0;<br>
+    if (a >= 0x0000000000000000L)<br>
+        return 0;<br>
+<br>
+    if (0x0000000000000000L == a)<br>
+        return 0;<br>
+    if (0x0000000000000000L != a)<br>
+        return 0;<br>
+    if (0x0000000000000000L < a)<br>
+        return 0;<br>
+    if (0x0000000000000000L <= a)<br>
+        return 0;<br>
+    if (0x0000000000000000L > a)<br>
+        return 0;<br>
+    if (0x0000000000000000L >= a)<br>
+        return 0;<br>
+<br>
+    if (a == 0x0000000000000000UL)<br>
+        return 0;<br>
+    if (a != 0x0000000000000000UL)<br>
+        return 0;<br>
+    if (a < 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}<br>
+        return 0;<br>
+    if (a <= 0x0000000000000000UL)<br>
+        return 0;<br>
+    if (a > 0x0000000000000000UL)<br>
+        return 0;<br>
+    if (a >= 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}}<br>
+        return 0;<br>
+<br>
+    if (0x0000000000000000UL == a)<br>
+        return 0;<br>
+    if (0x0000000000000000UL != a)<br>
+        return 0;<br>
+    if (0x0000000000000000UL < a)<br>
+        return 0;<br>
+    if (0x0000000000000000UL <= a) // expected-warning {{comparison of 0 <= unsigned expression is always true}}<br>
+        return 0;<br>
+    if (0x0000000000000000UL > a) // expected-warning {{comparison of 0 > unsigned expression is always false}}<br>
+        return 0;<br>
+    if (0x0000000000000000UL >= a)<br>
+        return 0;<br>
+<br>
     if (a == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}<br>
         return 0;<br>
     if (a != 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}<br>
@@ -74,6 +127,7 @@ int main()<br>
         return 0;<br>
     if (0x1234567812345678L >= s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}<br>
         return 0;<br>
+<br>
     long l = value();<br>
     if (l == 0x1234567812345678L)<br>
         return 0;<br>
@@ -106,13 +160,13 @@ int main()<br>
         return 0;<br>
     if (un != 0x0000000000000000L)<br>
         return 0;<br>
-    if (un < 0x0000000000000000L)<br>
+    if (un < 0x0000000000000000L) // expected-warning {{comparison of unsigned expression < 0 is always false}}<br>
         return 0;<br>
     if (un <= 0x0000000000000000L)<br>
         return 0;<br>
     if (un > 0x0000000000000000L)<br>
         return 0;<br>
-    if (un >= 0x0000000000000000L)<br>
+    if (un >= 0x0000000000000000L) // expected-warning {{comparison of unsigned expression >= 0 is always true}}<br>
         return 0;<br>
<br>
     if (0x0000000000000000L == un)<br>
@@ -121,19 +175,92 @@ int main()<br>
         return 0;<br>
     if (0x0000000000000000L < un)<br>
         return 0;<br>
-    if (0x0000000000000000L <= un)<br>
+    if (0x0000000000000000L <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}<br>
         return 0;<br>
-    if (0x0000000000000000L > un)<br>
+    if (0x0000000000000000L > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}<br>
         return 0;<br>
     if (0x0000000000000000L >= un)<br>
         return 0;<br>
+<br>
+    if (un == 0x0000000000000000UL)<br>
+        return 0;<br>
+    if (un != 0x0000000000000000UL)<br>
+        return 0;<br>
+    if (un < 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression < 0 is always false}}<br>
+        return 0;<br>
+    if (un <= 0x0000000000000000UL)<br>
+        return 0;<br>
+    if (un > 0x0000000000000000UL)<br>
+        return 0;<br>
+    if (un >= 0x0000000000000000UL) // expected-warning {{comparison of unsigned expression >= 0 is always true}}<br>
+        return 0;<br>
+<br>
+    if (0x0000000000000000UL == un)<br>
+        return 0;<br>
+    if (0x0000000000000000UL != un)<br>
+        return 0;<br>
+    if (0x0000000000000000UL < un)<br>
+        return 0;<br>
+    if (0x0000000000000000UL <= un) // expected-warning {{comparison of 0 <= unsigned expression is always true}}<br>
+        return 0;<br>
+    if (0x0000000000000000UL > un) // expected-warning {{comparison of 0 > unsigned expression is always false}}<br>
+        return 0;<br>
+    if (0x0000000000000000UL >= un)<br>
+        return 0;<br>
+<br>
     float fl = 0;<br>
-    if (fl == 0x0000000000000000L) // no warning<br>
-      return 0;<br>
+    if (fl == 0x0000000000000000L)<br>
+        return 0;<br>
+    if (fl != 0x0000000000000000L)<br>
+        return 0;<br>
+    if (fl < 0x0000000000000000L)<br>
+        return 0;<br>
+    if (fl <= 0x0000000000000000L)<br>
+        return 0;<br>
+    if (fl > 0x0000000000000000L)<br>
+        return 0;<br>
+    if (fl >= 0x0000000000000000L)<br>
+        return 0;<br>
<br>
-    float dl = 0;<br>
-    if (dl == 0x0000000000000000L) // no warning<br>
-      return 0;<br>
+    if (0x0000000000000000L == fl)<br>
+        return 0;<br>
+    if (0x0000000000000000L != fl)<br>
+        return 0;<br>
+    if (0x0000000000000000L < fl)<br>
+        return 0;<br>
+    if (0x0000000000000000L <= fl)<br>
+        return 0;<br>
+    if (0x0000000000000000L > fl)<br>
+        return 0;<br>
+    if (0x0000000000000000L >= fl)<br>
+        return 0;<br>
+<br>
+    double dl = 0;<br>
+    if (dl == 0x0000000000000000L)<br>
+        return 0;<br>
+    if (dl != 0x0000000000000000L)<br>
+        return 0;<br>
+    if (dl < 0x0000000000000000L)<br>
+        return 0;<br>
+    if (dl <= 0x0000000000000000L)<br>
+        return 0;<br>
+    if (dl > 0x0000000000000000L)<br>
+        return 0;<br>
+    if (dl >= 0x0000000000000000L)<br>
+        return 0;<br>
+<br>
+    if (0x0000000000000000L == dl)<br>
+        return 0;<br>
+    if (0x0000000000000000L != dl)<br>
+        return 0;<br>
+    if (0x0000000000000000L < dl)<br>
+        return 0;<br>
+    if (0x0000000000000000L <= dl)<br>
+        return 0;<br>
+    if (0x0000000000000000L > dl)<br>
+        return 0;<br>
+    if (0x0000000000000000L >= dl)<br>
+        return 0;<br>
<br>
     enum E {<br>
     yes,<br>
<br>
Modified: cfe/trunk/test/SemaCXX/<wbr>compare.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/compare.cpp?rev=312750&r1=312749&r2=312750&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>SemaCXX/compare.cpp?rev=<wbr>312750&r1=312749&r2=312750&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/SemaCXX/<wbr>compare.cpp (original)<br>
+++ cfe/trunk/test/SemaCXX/<wbr>compare.cpp Thu Sep  7 15:14:25 2017<br>
@@ -73,7 +73,7 @@ int test0(long a, unsigned long b) {<br>
          ((int) a == (unsigned int) B) +<br>
          ((short) a == (unsigned short) B) +<br>
          ((signed char) a == (unsigned char) B) +<br>
-         (a < (unsigned long) B) +  // expected-warning {{comparison of integers of different signs}}<br>
+         (a < (unsigned long) B) +  // expected-warning {{comparison of unsigned expression < 0 is always false}}<br>
          (a < (unsigned int) B) +<br>
          (a < (unsigned short) B) +<br>
          (a < (unsigned char) B) +<br>
@@ -81,8 +81,8 @@ int test0(long a, unsigned long b) {<br>
          ((int) a < B) +<br>
          ((short) a < B) +<br>
          ((signed char) a < B) +<br>
-         ((long) a < (unsigned long) B) +  // expected-warning {{comparison of integers of different signs}}<br>
-         ((int) a < (unsigned int) B) +  // expected-warning {{comparison of integers of different signs}}<br>
+         ((long) a < (unsigned long) B) +  // expected-warning {{comparison of unsigned expression < 0 is always false}}<br>
+         ((int) a < (unsigned int) B) +  // expected-warning {{comparison of unsigned expression < 0 is always false}}<br>
          ((short) a < (unsigned short) B) +<br>
          ((signed char) a < (unsigned char) B) +<br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>