aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-05-01 01:53:49 +0000
committerDouglas Gregor <dgregor@apple.com>2012-05-01 01:53:49 +0000
commit6d3b93d631640125f912339df19b0d2a15af5c9b (patch)
tree6cb4382efb097d995c67564f6f731bf5dfa235e2
parentc30636a160c640f32f847637004a2632b88cad6c (diff)
Turn the mixed-sign-comparison diagnostic into a runtime behavior
diagnostic, from Eitan Adler! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155876 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaChecking.cpp7
-rw-r--r--test/Sema/compare.c7
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 979a646442..002c985e0c 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -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.
diff --git a/test/Sema/compare.c b/test/Sema/compare.c
index 03aebb3a04..406ade81aa 100644
--- a/test/Sema/compare.c
+++ b/test/Sema/compare.c
@@ -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) { }
+}