diff options
author | Erich Keane <erich.keane@intel.com> | 2017-09-21 19:58:55 +0000 |
---|---|---|
committer | Erich Keane <erich.keane@intel.com> | 2017-09-21 19:58:55 +0000 |
commit | 69dbbb0bca7c4eb1bc3e15412393d7d23fffbdd2 (patch) | |
tree | b6890d620b52943dc14ce4094e5eaa437dc5fce4 /clang/lib/Sema/SemaChecking.cpp | |
parent | 4fbaa62b60b872654a5e2dbfd68337dc34b5f8cc (diff) | |
download | bcm5719-llvm-69dbbb0bca7c4eb1bc3e15412393d7d23fffbdd2.tar.gz bcm5719-llvm-69dbbb0bca7c4eb1bc3e15412393d7d23fffbdd2.zip |
Suppress Wsign-conversion for enums with matching underlying type
As reported here: https://bugs.llvm.org/show_bug.cgi?id=34692
A non-defined enum with a backing type was always defaulting to
being treated as a signed type. IN the case where it IS defined,
the signed-ness of the actual items is used.
This patch uses the underlying type's signed-ness in the non-defined
case to test signed-comparision.
Differential Revision: https://reviews.llvm.org/D38145
llvm-svn: 313907
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 87634ad57e5..956136859a0 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -8171,8 +8171,11 @@ struct IntRange { // For enum types, use the known bit width of the enumerators. if (const EnumType *ET = dyn_cast<EnumType>(T)) { 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()) - return IntRange(C.getIntWidth(QualType(T, 0)), false); + return IntRange(C.getIntWidth(QualType(T, 0)), + !ET->isSignedIntegerOrEnumerationType()); unsigned NumPositive = Enum->getNumPositiveBits(); unsigned NumNegative = Enum->getNumNegativeBits(); |