From: Ted Kremenek Date: Tue, 1 Mar 2011 19:13:22 +0000 (+0000) Subject: Don't warning about shifting by too many bits in dead code. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=425a31e03a619d50f5f958433fcdc533788e41b7;p=clang Don't warning about shifting by too many bits in dead code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126770 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 82ec6ee6e1..3da647acb2 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -6648,7 +6648,9 @@ static void DiagnoseBadShiftValues(Sema& S, Expr *&lex, Expr *&rex, llvm::APInt LeftBits(Right.getBitWidth(), S.Context.getTypeSize(lex->getType())); if (Right.uge(LeftBits)) { - S.Diag(Loc, diag::warn_shift_gt_typewidth) << rex->getSourceRange(); + S.DiagRuntimeBehavior(Loc, rex, + S.PDiag(diag::warn_shift_gt_typewidth) + << rex->getSourceRange()); return; } if (Opc != BO_Shl) diff --git a/test/Sema/shift.c b/test/Sema/shift.c index d75b5462cf..28407be079 100644 --- a/test/Sema/shift.c +++ b/test/Sema/shift.c @@ -60,3 +60,9 @@ enum { b = (a << ashift) }; void test_pr5544() { (void) (((1) > 63 && (1) < 128 ? (((unsigned long long) 1)<<((1)-64)) : (unsigned long long) 0)); // no-warning } + +void test_shift_too_much(char x) { + if (0) + (void) (x >> 80); // no-warning + (void) (x >> 80); // expected-warning {{shift count >= width of type}} +}