summaryrefslogtreecommitdiffstats
path: root/clang/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-08-23 22:08:35 +0000
committerChris Lattner <sabre@nondot.org>2007-08-23 22:08:35 +0000
commit247ef955bc0bbf00a528054074a97d81245f224b (patch)
tree134d059281bf4885bc42e45ba14349af67d6bb88 /clang/Sema/SemaStmt.cpp
parent8ddb23a6c5a69de8247f644f7d0e909675fdf821 (diff)
downloadbcm5719-llvm-247ef955bc0bbf00a528054074a97d81245f224b.tar.gz
bcm5719-llvm-247ef955bc0bbf00a528054074a97d81245f224b.zip
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. llvm-svn: 41343
Diffstat (limited to 'clang/Sema/SemaStmt.cpp')
-rw-r--r--clang/Sema/SemaStmt.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/Sema/SemaStmt.cpp b/clang/Sema/SemaStmt.cpp
index dff057456e2..18957240974 100644
--- a/clang/Sema/SemaStmt.cpp
+++ b/clang/Sema/SemaStmt.cpp
@@ -180,13 +180,16 @@ void Sema::ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &Val,
// 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)
OpenPOWER on IntegriCloud