diff options
author | Richard Trieu <rtrieu@google.com> | 2012-11-16 01:32:40 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2012-11-16 01:32:40 +0000 |
commit | 08b5fef122e899179c12c05792cd48dc36e2d319 (patch) | |
tree | ec504b5f0f49ea8b1b0a508b430f3cff7dc59903 /clang/lib/Sema/SemaChecking.cpp | |
parent | c08fa185961a38a1d972ccc7267206d0382f81f3 (diff) | |
download | bcm5719-llvm-08b5fef122e899179c12c05792cd48dc36e2d319.tar.gz bcm5719-llvm-08b5fef122e899179c12c05792cd48dc36e2d319.zip |
Take into account the zero sign bit for positive numbers when computing the bit
width of an enum with negative values in IntRange. Include a test for
-Wtautological-constant-out-of-range-compare where this had manifested.
llvm-svn: 168126
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 05fa2a06637..8e0a983d127 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -3922,7 +3922,11 @@ struct IntRange { unsigned NumPositive = Enum->getNumPositiveBits(); unsigned NumNegative = Enum->getNumNegativeBits(); - return IntRange(std::max(NumPositive, NumNegative), NumNegative == 0); + if (NumNegative == 0) + return IntRange(NumPositive, true/*NonNegative*/); + else + return IntRange(std::max(NumPositive + 1, NumNegative), + false/*NonNegative*/); } const BuiltinType *BT = cast<BuiltinType>(T); |