From: Jonathan Wakely Date: Wed, 4 Jul 2018 13:59:21 +0000 (+0100) Subject: Add workaround to std::variant for Clang bug 31852 X-Git-Tag: releases/gcc-7.4.0~282 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6c090cd5ff339489a263647019c8645834625be;p=thirdparty%2Fgcc.git Add workaround to std::variant for Clang bug 31852 Backport from mainline 2018-03-26 Jonathan Wakely * include/std/variant (__get): Qualify calls to avoid ADL. (__select_index): Adjust whitespace. (variant): Add using-declaration to workaround Clang bug. From-SVN: r262407 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 65ffd2c708b2..e0f4d61e33bf 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,12 @@ 2018-07-04 Jonathan Wakely + Backport from mainline + 2018-03-26 Jonathan Wakely + + * include/std/variant (__get): Qualify calls to avoid ADL. + (__select_index): Adjust whitespace. + (variant): Add using-declaration to workaround Clang bug. + Backport from mainline 2018-05-24 Maya Rashish diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index b31d774375d5..6762a7bb250b 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -229,13 +229,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template constexpr decltype(auto) __get(in_place_index_t<_Np>, _Union&& __u) - { return __get(in_place_index<_Np-1>, std::forward<_Union>(__u)._M_rest); } + { + return __variant::__get(in_place_index<_Np-1>, + std::forward<_Union>(__u)._M_rest); + } // Returns the typed storage for __v. template constexpr decltype(auto) __get(_Variant&& __v) { - return __get(std::in_place_index<_Np>, std::forward<_Variant>(__v)._M_u); + return __variant::__get(std::in_place_index<_Np>, + std::forward<_Variant>(__v)._M_u); } // Various functions as "vtable" entries, where those vtables are used by @@ -324,10 +328,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template using __select_index = - typename __select_int::_Select_int_base - ::type::value_type; + unsigned short>::type::value_type; template struct _Variant_storage @@ -1159,6 +1162,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #undef _VARIANT_RELATION_FUNCTION_TEMPLATE +#ifdef __clang__ + public: + using _Base::_M_u; // See https://bugs.llvm.org/show_bug.cgi?id=31852 + private: +#endif + template friend constexpr decltype(auto) __detail::__variant:: #if _GLIBCXX_INLINE_VERSION