[PATCH] D38145: Suppress Wsign-conversion for enums with matching underlying type

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 21 13:00:36 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL313907: Suppress Wsign-conversion for enums with matching underlying type (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D38145?vs=116245&id=116252#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38145

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp


Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -8171,8 +8171,11 @@
     // 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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38145.116252.patch
Type: text/x-patch
Size: 866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170921/5563b178/attachment.bin>


More information about the cfe-commits mailing list