From: Ted Kremenek Date: Tue, 1 Mar 2011 18:09:31 +0000 (+0000) Subject: Don't wanr about "negative shifts" in code that is unreachable. Fixes PR 5544. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=082bf7a47f78ff4a645cea358d70bf45a858b238;p=clang Don't wanr about "negative shifts" in code that is unreachable. Fixes PR 5544. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126762 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 321e96f1e7..bc2251a4e0 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -6641,7 +6641,9 @@ static void DiagnoseBadShiftValues(Sema& S, Expr *&lex, Expr *&rex, return; if (Right.isNegative()) { - S.Diag(Loc, diag::warn_shift_negative) << rex->getSourceRange(); + S.DiagRuntimeBehavior(Loc, rex, + S.PDiag(diag::warn_shift_negative) + << rex->getSourceRange()); return; } llvm::APInt LeftBits(Right.getBitWidth(), diff --git a/test/Sema/shift.c b/test/Sema/shift.c index df6b1141bd..d75b5462cf 100644 --- a/test/Sema/shift.c +++ b/test/Sema/shift.c @@ -56,3 +56,7 @@ void test() { #define ashift 8 enum { b = (a << ashift) }; +// Don't warn for negative shifts in code that is unreachable. +void test_pr5544() { + (void) (((1) > 63 && (1) < 128 ? (((unsigned long long) 1)<<((1)-64)) : (unsigned long long) 0)); // no-warning +}