[cfe-commits] r126770 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/shift.c
Ted Kremenek
kremenek at apple.com
Tue Mar 1 11:13:22 PST 2011
Author: kremenek
Date: Tue Mar 1 13:13:22 2011
New Revision: 126770
URL: http://llvm.org/viewvc/llvm-project?rev=126770&view=rev
Log:
Don't warning about shifting by too many bits in dead code.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/shift.c
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=126770&r1=126769&r2=126770&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Mar 1 13:13:22 2011
@@ -6648,7 +6648,9 @@
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)
Modified: cfe/trunk/test/Sema/shift.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/shift.c?rev=126770&r1=126769&r2=126770&view=diff
==============================================================================
--- cfe/trunk/test/Sema/shift.c (original)
+++ cfe/trunk/test/Sema/shift.c Tue Mar 1 13:13:22 2011
@@ -60,3 +60,9 @@
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}}
+}
More information about the cfe-commits
mailing list