aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-11-30 23:09:29 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-11-30 23:09:29 +0000
commitd87de7bdbc25dd84ae3dbefffda4539c443000d2 (patch)
tree92ed861701bee1b15db0bd539a29ce13057c9404 /lib/Sema/SemaChecking.cpp
parent4565e487531c7bf6d348dbe9f5529784966fc7ae (diff)
Make -Wtautological-constant-out-of-range-compare behave sanely for enums with a signed fixed type.
<rdar://problem/12780159>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169051 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 33dcb3a6cb..235383fdd1 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -4346,7 +4346,6 @@ static void DiagnoseOutOfRangeComparison(Sema &S, BinaryOperator *E,
&& "comparison with non-integer type");
bool ConstantSigned = ConstantT->isSignedIntegerType();
- bool OtherSigned = OtherT->isSignedIntegerType();
bool CommonSigned = CommonT->isSignedIntegerType();
bool EqualityOnly = false;
@@ -4358,7 +4357,7 @@ static void DiagnoseOutOfRangeComparison(Sema &S, BinaryOperator *E,
if (CommonSigned) {
// The common type is signed, therefore no signed to unsigned conversion.
- if (OtherSigned) {
+ if (!OtherRange.NonNegative) {
// Check that the constant is representable in type OtherT.
if (ConstantSigned) {
if (OtherWidth >= Value.getMinSignedBits())
@@ -4379,10 +4378,10 @@ static void DiagnoseOutOfRangeComparison(Sema &S, BinaryOperator *E,
}
}
} else { // !CommonSigned
- if (!OtherSigned) {
+ if (OtherRange.NonNegative) {
if (OtherWidth >= Value.getActiveBits())
return;
- } else if (OtherSigned && !ConstantSigned) {
+ } else if (!OtherRange.NonNegative && !ConstantSigned) {
// Check to see if the constant is representable in OtherT.
if (OtherWidth > Value.getActiveBits())
return;