]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Enable __has_builtin for new reference binding built-ins
authorJonathan Wakely <jwakely@redhat.com>
Tue, 19 Jul 2022 09:55:52 +0000 (10:55 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 19 Jul 2022 14:12:27 +0000 (15:12 +0100)
The new built-ins need to be detectable using __has_builtin, and the
library should use that to check for them.

This fixes an error with Clang when C++23 is enabled.

gcc/cp/ChangeLog:

* cp-objcp-common.cc (names_builtin_p): Return true for
RID_REF_CONSTRUCTS_FROM_TEMPORARY and
RID_REF_CONVERTS_FROM_TEMPORARY.

libstdc++-v3/ChangeLog:

* include/std/type_traits (__cpp_lib_reference_from_temporary)
(reference_constructs_from_temporary)
(reference_converts_from_temporary): Only define when the
built-ins are available.

gcc/cp/cp-objcp-common.cc
libstdc++-v3/include/std/type_traits

index 0b70d5567e47e73308173d009eb0baffa84ca21e..4079a4b4aecf85a54cd714913315e2c106687499 100644 (file)
@@ -461,6 +461,8 @@ names_builtin_p (const char *name)
     case RID_IS_ASSIGNABLE:
     case RID_IS_CONSTRUCTIBLE:
     case RID_UNDERLYING_TYPE:
+    case RID_REF_CONSTRUCTS_FROM_TEMPORARY:
+    case RID_REF_CONVERTS_FROM_TEMPORARY:
       return true;
     default:
       break;
index b1a1deecf664911ba84eba57320d8014d15da8f0..14b029cec64402ee47756b318acbf3233a5432b7 100644 (file)
@@ -3505,6 +3505,9 @@ template<typename _Ret, typename _Fn, typename... _Args>
   template<typename _Tp>
     inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
 
+#if __has_builtin(__reference_constructs_from_temporary) \
+  && __has_builtin(__reference_converts_from_temporary)
+
 #define __cpp_lib_reference_from_temporary 202202L
 
   /// True if _Tp is a reference type, a _Up value can be bound to _Tp in
@@ -3544,6 +3547,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
   template<typename _Tp, typename _Up>
     inline constexpr bool reference_converts_from_temporary_v
       = reference_converts_from_temporary<_Tp, _Up>::value;
+#endif // __has_builtin for reference_from_temporary
 #endif // C++23
 
 #if _GLIBCXX_HAVE_IS_CONSTANT_EVALUATED