diff options
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 6 | ||||
-rw-r--r-- | test/Sema/switch.c | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index d9f5b38eb9..bdd0962a11 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -340,11 +340,11 @@ void Sema::ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &Val, } 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); } } diff --git a/test/Sema/switch.c b/test/Sema/switch.c index 9905c4b025..213cd0a75b 100644 --- a/test/Sema/switch.c +++ b/test/Sema/switch.c @@ -240,3 +240,17 @@ int test13(my_type_t t) { } return -1; } + +// <rdar://problem/7658121> +enum { + EC0 = 0xFFFF0000, + EC1 = 0xFFFF0001, +}; + +int test14(int a) { + switch(a) { + case EC0: return 0; + case EC1: return 1; + } + return 0; +} |