Don't diagnose overflow in case statements when the conversion is a
signed<->unsigned conversion with the same bit width. Fixes
<rdar://problem/7658121>.
llvm-svn: 96545
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index d9f5b38..bdd0962 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -340,11 +340,11 @@
} else if (NewSign != Val.isSigned()) {
// Convert the sign to match the sign of the condition. This can cause
// overflow as well: unsigned(INTMIN)
+ // We don't diagnose this overflow, because it is implementation-defined
+ // behavior.
+ // FIXME: Introduce a second, default-ignored warning for this case?
llvm::APSInt OldVal(Val);
Val.setIsSigned(NewSign);
-
- if (Val.isNegative()) // Sign bit changes meaning.
- Diag(Loc, DiagID) << OldVal.toString(10) << Val.toString(10);
}
}