From: Jonathan Wakely Date: Wed, 30 Sep 2020 17:24:48 +0000 (+0100) Subject: libstdc++: Use __is_same instead of __is_same_as X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=r11-3569-g73ae6eb572515ad627b575a7fbdfdd47a4368e1c;p=gcc.git libstdc++: Use __is_same instead of __is_same_as PR 92271 added __is_same as another spelling of __is_same_as. Since Clang also spells it __is_same, let's just use that consistently. It appears that Intel icc sets __GNUC__ to 10, but only supports __is_same_as. If we only use __is_same for __GNUC__ >= 11 then we won't break icc again (it looks like we broke previous versions of icc when we started using __is_same_as). libstdc++-v3/ChangeLog: * include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_IS_SAME): Define for GCC 11 or when !__is_identifier(__is_same). (_GLIBCXX_BUILTIN_IS_SAME_AS): Remove. * include/std/type_traits (is_same, is_same_v): Replace uses of _GLIBCXX_BUILTIN_IS_SAME_AS. --- diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 860bf6dbcb3..2e6c880ad95 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -658,10 +658,12 @@ namespace std # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1 # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 -# define _GLIBCXX_BUILTIN_IS_SAME_AS(T, U) __is_same_as(T, U) # if __GNUC__ >= 9 # define _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED 1 # endif +# if __GNUC__ >= 11 +# define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1 +# endif #elif defined(__is_identifier) && defined(__has_builtin) // For non-GNU compilers: # if ! __is_identifier(__has_unique_object_representations) @@ -677,7 +679,7 @@ namespace std # define _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED 1 # endif # if ! __is_identifier(__is_same) -# define _GLIBCXX_BUILTIN_IS_SAME_AS(T, U) __is_same(T, U) +# define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1 # endif #endif // GCC diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index b7bb63bbc74..9994c9ae3d7 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1394,14 +1394,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_same template struct is_same -#ifdef _GLIBCXX_BUILTIN_IS_SAME_AS - : public integral_constant +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME + : public integral_constant #else : public false_type #endif { }; -#ifndef _GLIBCXX_BUILTIN_IS_SAME_AS +#ifndef _GLIBCXX_HAVE_BUILTIN_IS_SAME template struct is_same<_Tp, _Tp> : public true_type @@ -3215,9 +3215,9 @@ template inline constexpr size_t rank_v = rank<_Tp>::value; template inline constexpr size_t extent_v = extent<_Tp, _Idx>::value; -#ifdef _GLIBCXX_BUILTIN_IS_SAME_AS +#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME template - inline constexpr bool is_same_v = _GLIBCXX_BUILTIN_IS_SAME_AS(_Tp, _Up); + inline constexpr bool is_same_v = __is_same(_Tp, _Up); #else template inline constexpr bool is_same_v = std::is_same<_Tp, _Up>::value;