aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-03-01 19:13:22 +0000
committerTed Kremenek <kremenek@apple.com>2011-03-01 19:13:22 +0000
commit425a31e03a619d50f5f958433fcdc533788e41b7 (patch)
tree35fd75e5aad0c3b544c22689408ef2f99585b27b
parentd25f485fdf0235dd030b7669bc72760b700f704a (diff)
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
-rw-r--r--lib/Sema/SemaExpr.cpp4
-rw-r--r--test/Sema/shift.c6
2 files changed, 9 insertions, 1 deletions
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}}
+}