[cfe-commits] r41343 - /cfe/trunk/Sema/SemaStmt.cpp
Chris Lattner
sabre at nondot.org
Thu Aug 23 15:08:35 PDT 2007
Author: lattner
Date: Thu Aug 23 17:08:35 2007
New Revision: 41343
URL: http://llvm.org/viewvc/llvm-project?rev=41343&view=rev
Log:
in the truncation case, make sure to propagate the sign correctly, this
fixes an assertion on:
void f (int z) { switch (z) { case ~0ULL: case -1: return; } }
testcase from Neil.
Modified:
cfe/trunk/Sema/SemaStmt.cpp
Modified: cfe/trunk/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaStmt.cpp?rev=41343&r1=41342&r2=41343&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/Sema/SemaStmt.cpp Thu Aug 23 17:08:35 2007
@@ -180,13 +180,16 @@
// If this is a truncation, check for overflow.
llvm::APSInt ConvVal(Val);
ConvVal.trunc(NewWidth);
+ ConvVal.setIsSigned(NewSign);
ConvVal.extend(Val.getBitWidth());
+ ConvVal.setIsSigned(Val.isSigned());
if (ConvVal != Val)
Diag(Loc, DiagID, Val.toString(), ConvVal.toString());
// Regardless of whether a diagnostic was emitted, really do the
// truncation.
Val.trunc(NewWidth);
+ Val.setIsSigned(NewSign);
} else if (NewSign != Val.isSigned()) {
// Convert the sign to match the sign of the condition. This can cause
// overflow as well: unsigned(INTMIN)
More information about the cfe-commits
mailing list