aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-12-06 03:00:51 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-12-06 03:00:51 +0000
commit371e9e8a28517f4da559fed3d44877a5a1b3e785 (patch)
tree0de8955d037a756be463236ec005801e0f8ad5b7 /clang/lib/Sema/SemaChecking.cpp
parenta834b529c3ed85ed75cb875517751b3350d6cecc (diff)
downloadllvm-371e9e8a28517f4da559fed3d44877a5a1b3e785.zip
llvm-371e9e8a28517f4da559fed3d44877a5a1b3e785.tar.gz
llvm-371e9e8a28517f4da559fed3d44877a5a1b3e785.tar.bz2
Fix a bunch of wrong "tautological unsigned enum compare" diagnostics in C++.
An enumeration with a fixed underlying type can have any value in its underlying type, not just those spanned by the values of its enumerators. llvm-svn: 319875
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index e23db3e..184f98d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -8260,11 +8260,12 @@ struct IntRange {
} else if (const EnumType *ET = dyn_cast<EnumType>(T)) {
// For enum types in C++, use the known bit width of the enumerators.
EnumDecl *Enum = ET->getDecl();
- // In C++11, enums without definitions can have an explicitly specified
- // underlying type. Use this type to compute the range.
- if (!Enum->isCompleteDefinition())
+ // In C++11, enums can have a fixed underlying type. Use this type to
+ // compute the range.
+ if (Enum->isFixed()) {
return IntRange(C.getIntWidth(QualType(T, 0)),
!ET->isSignedIntegerOrEnumerationType());
+ }
unsigned NumPositive = Enum->getNumPositiveBits();
unsigned NumNegative = Enum->getNumNegativeBits();