Re: [libcxx] r307751 - Fix unrepresentable enum for clang-cl unstable ABI
That was what the diff was doing originally (see https://reviews.llvm.org/D35174?id=105752), but Eric suggested switching to static consts (presumably to work regardless of enum class availability). From: cfe-commits <cfe-commits-boun...@lists.llvm.org> on behalf of David Majnemer via cfe-commits <cfe-commits@lists.llvm.org> Reply-To: David Majnemer <david.majne...@gmail.com> Date: Tuesday, July 11, 2017 at 10:57 PM To: Ben Craig <ben.cr...@ni.com> Cc: cfe-commits <cfe-commits@lists.llvm.org> Subject: Re: [libcxx] r307751 - Fix unrepresentable enum for clang-cl unstable ABI FWIW, I think you could just give the enum an explicit underlying type of size_type. On Tue, Jul 11, 2017 at 6:45 PM, Ben Craig via cfe-commits <cfe-commits@lists.llvm.org<mailto:cfe-commits@lists.llvm.org>> wrote: Author: bcraig Date: Tue Jul 11 18:45:13 2017 New Revision: 307751 URL: http://llvm.org/viewvc/llvm-project?rev=307751=rev<https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D307751-26view-3Drev=DwMFaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=Al3ss93XugI9bIwKEbCwGSEAjNpwS59a2_0TYpj2V5o=WBppCMWm-1SBMOSildXNOcNjOEVkEATVVmpWqBT6ppY=> Log: Fix unrepresentable enum for clang-cl unstable ABI 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 switching from enums to static const size_type. https://reviews.llvm.org/D35174<https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D35174=DwMFaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=Al3ss93XugI9bIwKEbCwGSEAjNpwS59a2_0TYpj2V5o=QkYzJCsy03aP5Id5cIPbMy2h89BSMHFTQRk3vzDGwOY=> Modified: libcxx/trunk/include/string Modified: libcxx/trunk/include/string URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=307751=307750=307751=diff<https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_libcxx_trunk_include_string-3Frev-3D307751-26r1-3D307750-26r2-3D307751-26view-3Ddiff=DwMFaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=Al3ss93XugI9bIwKEbCwGSEAjNpwS59a2_0TYpj2V5o=Dl5rZ9I376arg_gWk2SdVEbVwSnXPhQyB3bqELKhnmw=> == --- libcxx/trunk/include/string (original) +++ libcxx/trunk/include/string Tue Jul 11 18:45:13 2017 @@ -676,11 +676,11 @@ private: }; #if _LIBCPP_BIG_ENDIAN -enum {__short_mask = 0x01}; -enum {__long_mask = 0x1ul}; +static const size_type __short_mask = 0x01; +static const size_type __long_mask = 0x1ul; #else // _LIBCPP_BIG_ENDIAN -enum {__short_mask = 0x80}; -enum {__long_mask = ~(size_type(~0) >> 1)}; +static const size_type __short_mask = 0x80; +static const size_type __long_mask = ~(size_type(~0) >> 1); #endif // _LIBCPP_BIG_ENDIAN enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? @@ -706,11 +706,11 @@ private: }; #if _LIBCPP_BIG_ENDIAN -enum {__short_mask = 0x80}; -enum {__long_mask = ~(size_type(~0) >> 1)}; +static const size_type __short_mask = 0x80; +static const size_type __long_mask = ~(size_type(~0) >> 1); #else // _LIBCPP_BIG_ENDIAN -enum {__short_mask = 0x01}; -enum {__long_mask = 0x1ul}; +static const size_type __short_mask = 0x01; +static const size_type __long_mask = 0x1ul; #endif // _LIBCPP_BIG_ENDIAN enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? ___ cfe-commits mailing list cfe-commits@lists.llvm.org<mailto:cfe-commits@lists.llvm.org> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits<https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits=DwMFaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=Al3ss93XugI9bIwKEbCwGSEAjNpwS59a2_0TYpj2V5o=4uXP_QwyDcL_9jZSny3SFj2dvf81DxOnu21QJBi_ANQ=> ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r307751 - Fix unrepresentable enum for clang-cl unstable ABI
FWIW, I think you could just give the enum an explicit underlying type of size_type. On Tue, Jul 11, 2017 at 6:45 PM, Ben Craig via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: bcraig > Date: Tue Jul 11 18:45:13 2017 > New Revision: 307751 > > URL: http://llvm.org/viewvc/llvm-project?rev=307751=rev > Log: > Fix unrepresentable enum for clang-cl unstable ABI > > 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 switching from enums to static const size_type. > > https://reviews.llvm.org/D35174 > > Modified: > libcxx/trunk/include/string > > Modified: libcxx/trunk/include/string > URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ > string?rev=307751=307750=307751=diff > > == > --- libcxx/trunk/include/string (original) > +++ libcxx/trunk/include/string Tue Jul 11 18:45:13 2017 > @@ -676,11 +676,11 @@ private: > }; > > #if _LIBCPP_BIG_ENDIAN > -enum {__short_mask = 0x01}; > -enum {__long_mask = 0x1ul}; > +static const size_type __short_mask = 0x01; > +static const size_type __long_mask = 0x1ul; > #else // _LIBCPP_BIG_ENDIAN > -enum {__short_mask = 0x80}; > -enum {__long_mask = ~(size_type(~0) >> 1)}; > +static const size_type __short_mask = 0x80; > +static const size_type __long_mask = ~(size_type(~0) >> 1); > #endif // _LIBCPP_BIG_ENDIAN > > enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? > @@ -706,11 +706,11 @@ private: > }; > > #if _LIBCPP_BIG_ENDIAN > -enum {__short_mask = 0x80}; > -enum {__long_mask = ~(size_type(~0) >> 1)}; > +static const size_type __short_mask = 0x80; > +static const size_type __long_mask = ~(size_type(~0) >> 1); > #else // _LIBCPP_BIG_ENDIAN > -enum {__short_mask = 0x01}; > -enum {__long_mask = 0x1ul}; > +static const size_type __short_mask = 0x01; > +static const size_type __long_mask = 0x1ul; > #endif // _LIBCPP_BIG_ENDIAN > > enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r307751 - Fix unrepresentable enum for clang-cl unstable ABI
Author: bcraig Date: Tue Jul 11 18:45:13 2017 New Revision: 307751 URL: http://llvm.org/viewvc/llvm-project?rev=307751=rev Log: Fix unrepresentable enum for clang-cl unstable ABI 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 switching from enums to static const size_type. https://reviews.llvm.org/D35174 Modified: libcxx/trunk/include/string Modified: libcxx/trunk/include/string URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=307751=307750=307751=diff == --- libcxx/trunk/include/string (original) +++ libcxx/trunk/include/string Tue Jul 11 18:45:13 2017 @@ -676,11 +676,11 @@ private: }; #if _LIBCPP_BIG_ENDIAN -enum {__short_mask = 0x01}; -enum {__long_mask = 0x1ul}; +static const size_type __short_mask = 0x01; +static const size_type __long_mask = 0x1ul; #else // _LIBCPP_BIG_ENDIAN -enum {__short_mask = 0x80}; -enum {__long_mask = ~(size_type(~0) >> 1)}; +static const size_type __short_mask = 0x80; +static const size_type __long_mask = ~(size_type(~0) >> 1); #endif // _LIBCPP_BIG_ENDIAN enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? @@ -706,11 +706,11 @@ private: }; #if _LIBCPP_BIG_ENDIAN -enum {__short_mask = 0x80}; -enum {__long_mask = ~(size_type(~0) >> 1)}; +static const size_type __short_mask = 0x80; +static const size_type __long_mask = ~(size_type(~0) >> 1); #else // _LIBCPP_BIG_ENDIAN -enum {__short_mask = 0x01}; -enum {__long_mask = 0x1ul}; +static const size_type __short_mask = 0x01; +static const size_type __long_mask = 0x1ul; #endif // _LIBCPP_BIG_ENDIAN enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits