summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-01 01:04:55 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-01 01:04:55 +0000
commita070ffa7b8f9dede25768ad8e24dfee4171b2840 (patch)
treeed2d5bc38c329c32bcfaf843b1f550b1dc91030a /clang/lib
parent560169d5c44ac3f1ec0a707fdfc62bef4bffb4fe (diff)
downloadbcm5719-llvm-a070ffa7b8f9dede25768ad8e24dfee4171b2840.tar.gz
bcm5719-llvm-a070ffa7b8f9dede25768ad8e24dfee4171b2840.zip
Don't warn about case-value conversions from a negative value to a
larger unsigned value, since this is implementation-defined behavior. (We previously suppressed this warning when converting from a signed value to an unsigned value of the same size). llvm-svn: 97430
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaStmt.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index bdd0962a11b..540189cd830 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -314,15 +314,13 @@ void Sema::ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &Val,
// Perform a conversion to the promoted condition type if needed.
if (NewWidth > Val.getBitWidth()) {
// If this is an extension, just do it.
- llvm::APSInt OldVal(Val);
Val.extend(NewWidth);
-
- // If the input was signed and negative and the output is unsigned,
- // warn.
- if (!NewSign && OldVal.isSigned() && OldVal.isNegative())
- Diag(Loc, DiagID) << OldVal.toString(10) << Val.toString(10);
-
Val.setIsSigned(NewSign);
+
+ // If the input was signed and negative and the output is
+ // unsigned, don't bother to warn: this is implementation-defined
+ // behavior.
+ // FIXME: Introduce a second, default-ignored warning for this case?
} else if (NewWidth < Val.getBitWidth()) {
// If this is a truncation, check for overflow.
llvm::APSInt ConvVal(Val);
OpenPOWER on IntegriCloud