]> granicus.if.org Git - clang/commitdiff
Turn the mixed-sign-comparison diagnostic into a runtime behavior
authorDouglas Gregor <dgregor@apple.com>
Tue, 1 May 2012 01:53:49 +0000 (01:53 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 1 May 2012 01:53:49 +0000 (01:53 +0000)
diagnostic, from Eitan Adler!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155876 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp
test/Sema/compare.c

index 979a64644243f98d98bf9304fff70716095c92f9..002c985e0c5b183a4575a053ec424261fe86faee 100644 (file)
@@ -3952,9 +3952,10 @@ static void AnalyzeComparison(Sema &S, BinaryOperator *E) {
       return;
   }
 
-  S.Diag(E->getOperatorLoc(), diag::warn_mixed_sign_comparison)
-    << LHS->getType() << RHS->getType()
-    << LHS->getSourceRange() << RHS->getSourceRange();
+  S.DiagRuntimeBehavior(E->getOperatorLoc(), E,
+    S.PDiag(diag::warn_mixed_sign_comparison)
+      << LHS->getType() << RHS->getType()
+      << LHS->getSourceRange() << RHS->getSourceRange());
 }
 
 /// Analyzes an attempt to assign the given value to a bitfield.
index 03aebb3a04620a425ac3622e615c23542f3e268c..406ade81aa0dfbeb06c95ffc82120f6f6ac0580d 100644 (file)
@@ -333,3 +333,10 @@ struct test11S { unsigned x : 30; };
 int test11(unsigned y, struct test11S *p) {
   return y > (p->x >> 24); // no-warning
 }
+
+typedef char one_char[1];
+typedef char two_chars[2];
+
+void test12(unsigned a) {
+  if (0 && -1 > a) { }
+}