Message ID | 20220719131102.2469016-1-jwakely@redhat.com |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp2439027eik; Tue, 19 Jul 2022 06:12:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vLrgztgguuwD0/rYHkFllmwv3N0SiJkmMs+rmpunAmcR4zBItOvVMBIogbZr9BBzHmXs39 X-Received: by 2002:a17:906:7482:b0:722:ea8f:3a12 with SMTP id e2-20020a170906748200b00722ea8f3a12mr31173364ejl.220.1658236329594; Tue, 19 Jul 2022 06:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658236329; cv=none; d=google.com; s=arc-20160816; b=nzRhayUV2GomslbWTfSniI6YkB5VaraWXsRBZcjnzr1tbEirmkmuI5jRf/+7IJqeDE R/JENw4XOdvocDG0p0g9UCKUl0dUclYC9ua5r6WckB+DwNy5HMuXDfhN/HPpjw1me3xz CZPPazxu5ZiMgCZIOD6iIxpFN7cbEYcTxetxzN2ffkq3yRp6ePdbl6vdF+QQJVfx5N3k t2fquLwHaEen0t+ySAc0URM9biwgWDd8tW/QGuDXz0ki67elkIaz9OOx8rYEuvX31sOn Sdl2y8R+IoMTYhe+eVBVn2D6vlx/Rei3j5+YmrepNO8b+i1+o+hwLXrK/DIMMdAOnUPY UJ4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=N835eM1g813WyjPtytclc1Z5cooi2K2ZJV2QbW8eMZg=; b=K/axIYL47aCADNr6oJIn+xD6qNBTKCV9xg1qHCv8VOnJiyJfw6QIb7UlnM/XemrInd DzLn1Jd1nLjTJiqx47251I5DlsK2O+uTIOjRqfEj839xH8rKslptiKPCk8DnIkkfLAp6 tRI1EAYifL18w9ak54cKOJyqcSw9s1YvHv+m/doCIqgaNo0fBnpIMr9ARx1xNeky5ZzF edzfsrla4G5UKrowpP8ryWg6w1+y112fKcy9HQ5S6lAnf9T3wXoR8nEpqb8GEU0Mvsp0 BkHXzNTvYjnGBO2SQ2GiodV8+7UEzCVlZRLLzl8yxqRX+7dF7uBFkD9of1aMymsFVykt u8ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tQJIBwUM; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id dd9-20020a1709069b8900b0072ee40a2056si19735030ejc.862.2022.07.19.06.12.09 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 06:12:09 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tQJIBwUM; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 649C7385741C for <ouuuleilei@gmail.com>; Tue, 19 Jul 2022 13:11:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 649C7385741C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658236311; bh=N835eM1g813WyjPtytclc1Z5cooi2K2ZJV2QbW8eMZg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=tQJIBwUMoVZSg9eiXBuX/o7/+BIhtYYwZTBJ/Kj0cgp9ec3YZTim1G53XlHlKTN2D gNnhRz0yexI+OUqLzhu/qmZ7mN1fy5h5O/Pwxlp+JPWLGFVMRhzAdSoMy9iuKSgAUa 8zOzyrymlEvG8pbkFNUNPt2D+fxDJSfmwlBEuQxY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E0EAC3858439 for <gcc-patches@gcc.gnu.org>; Tue, 19 Jul 2022 13:11:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E0EAC3858439 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-397-IW5QQGAeOlKnLO_nXZ2dpw-1; Tue, 19 Jul 2022 09:11:04 -0400 X-MC-Unique: IW5QQGAeOlKnLO_nXZ2dpw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D3361C06EDF; Tue, 19 Jul 2022 13:11:03 +0000 (UTC) Received: from localhost (unknown [10.33.36.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E03E40C1288; Tue, 19 Jul 2022 13:11:03 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Enable __has_builtin for new reference binding built-ins Date: Tue, 19 Jul 2022 14:11:02 +0100 Message-Id: <20220719131102.2469016-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jonathan Wakely <jwakely@redhat.com> Cc: Marek Polacek <polacek@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-LABELS: =?utf-8?b?IlxcSW1wb3J0YW50Ig==?= X-GMAIL-THRID: =?utf-8?q?1738786817608997172?= X-GMAIL-MSGID: =?utf-8?q?1738786817608997172?= |
Series |
c++: Enable __has_builtin for new reference binding built-ins
|
|
Commit Message
Li, Pan2 via Gcc-patches
July 19, 2022, 1:11 p.m. UTC
Tested x86_64-linux, OK for trunk? -- >8 -- 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 | 2 ++ libstdc++-v3/include/std/type_traits | 4 ++++ 2 files changed, 6 insertions(+)
Comments
On Tue, Jul 19, 2022 at 02:11:02PM +0100, Jonathan Wakely wrote: > Tested x86_64-linux, OK for trunk? > > -- >8 -- > > 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. LGTM but can't approve. Thanks and sorry for missing this! > 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 | 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<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 > -- > 2.34.3 > Marek
On 7/19/22 09:11, Jonathan Wakely wrote: > Tested x86_64-linux, OK for trunk? OK. > -- >8 -- > > 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 | 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<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
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<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