From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 601FB3853541; Tue, 19 Jul 2022 14:12:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 601FB3853541 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-1751] c++: Enable __has_builtin for new reference binding built-ins X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 4a8aab9a23550dbf53d4640fef57c0bd6f6b0129 X-Git-Newrev: 465802c0d40adca5fd5b0a2af6ff8a323a55b589 Message-Id: <20220719141238.601FB3853541@sourceware.org> Date: Tue, 19 Jul 2022 14:12:38 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jul 2022 14:12:38 -0000 https://gcc.gnu.org/g:465802c0d40adca5fd5b0a2af6ff8a323a55b589 commit r13-1751-g465802c0d40adca5fd5b0a2af6ff8a323a55b589 Author: Jonathan Wakely Date: Tue Jul 19 10:55:52 2022 +0100 c++: Enable __has_builtin for new reference binding built-ins 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. Diff: --- gcc/cp/cp-objcp-common.cc | 2 ++ libstdc++-v3/include/std/type_traits | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc index 0b70d5567e4..4079a4b4aec 100644 --- a/gcc/cp/cp-objcp-common.cc +++ b/gcc/cp/cp-objcp-common.cc @@ -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; diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index b1a1deecf66..14b029cec64 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -3505,6 +3505,9 @@ template template 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 template 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