aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaStmt.cpp
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
commitf9f627dbbc62fbf51b906c24c783b4249dc7e9bb (patch)
treed43325b481c5d6730a01cc3c1f7743217442d9a5 /lib/Sema/SemaStmt.cpp
parent3363b35e518c28b504d4a600dc8cb168324b17d5 (diff)
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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97430 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index bdd0962a11..540189cd83 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/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);