]> granicus.if.org Git - clang/commitdiff
Don't warning about shifting by too many bits in dead code.
authorTed Kremenek <kremenek@apple.com>
Tue, 1 Mar 2011 19:13:22 +0000 (19:13 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 1 Mar 2011 19:13:22 +0000 (19:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126770 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/Sema/shift.c

index 82ec6ee6e13144a2d076e569820194d9211f0f11..3da647acb2e6ad7168abc87b247b81efa805203e 100644 (file)
@@ -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)
index d75b5462cf8fdb0a303c23fa9f0212c19332d834..28407be079f45eca97cdcb66d868838c32ef32cc 100644 (file)
@@ -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}}
+}