[PATCH] D35174: [libc++] Fix unrepresentable enum for clang-cl unstable ABI
Ben Craig via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 9 06:15:09 PDT 2017
bcraig created this revision.
When using LIBCXX_ABI_UNSTABLE=YES, clang-cl gave the following warning:
P:\llvm_master\src\llvm\projects\libcxx\include\string(683,51):
warning: enumerator value is not representable in the underlying type
'int' [-Wmicrosoft-enum-value]
Fixed by providing a sufficiently large representation, so long as C++11
strong enums are available.
https://reviews.llvm.org/D35174
Files:
include/__config
include/string
Index: include/string
===================================================================
--- include/string
+++ include/string
@@ -680,7 +680,7 @@
enum {__long_mask = 0x1ul};
#else // _LIBCPP_BIG_ENDIAN
enum {__short_mask = 0x80};
- enum {__long_mask = ~(size_type(~0) >> 1)};
+ enum _LIBCPP_UNDERLYING_ENUM_TYPE(size_type) {__long_mask = ~(size_type(~0) >> 1)};
#endif // _LIBCPP_BIG_ENDIAN
enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
@@ -707,7 +707,7 @@
#if _LIBCPP_BIG_ENDIAN
enum {__short_mask = 0x80};
- enum {__long_mask = ~(size_type(~0) >> 1)};
+ enum _LIBCPP_UNDERLYING_ENUM_TYPE(size_type) {__long_mask = ~(size_type(~0) >> 1)};
#else // _LIBCPP_BIG_ENDIAN
enum {__short_mask = 0x01};
enum {__long_mask = 0x1ul};
Index: include/__config
===================================================================
--- include/__config
+++ include/__config
@@ -849,9 +849,11 @@
_LIBCPP_ALWAYS_INLINE explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \
_LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} \
};
+#define _LIBCPP_UNDERLYING_ENUM_TYPE(t)
#else // _LIBCPP_HAS_NO_STRONG_ENUMS
#define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x
#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x)
+#define _LIBCPP_UNDERLYING_ENUM_TYPE(t) : t
#endif // _LIBCPP_HAS_NO_STRONG_ENUMS
#ifdef _LIBCPP_DEBUG
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35174.105752.patch
Type: text/x-patch
Size: 1420 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170709/17c16b10/attachment-0001.bin>
More information about the cfe-commits
mailing list