From 6d3b93d631640125f912339df19b0d2a15af5c9b Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 1 May 2012 01:53:49 +0000 Subject: [PATCH] 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 --- lib/Sema/SemaChecking.cpp | 7 ++++--- test/Sema/compare.c | 7 +++++++ 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) { } +} -- 2.40.0