From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 7D16E386FC23 for ; Fri, 6 Aug 2021 13:29:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D16E386FC23 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-423--ZZNCN8XMM6nynCX0IEQpg-1; Fri, 06 Aug 2021 09:29:40 -0400 X-MC-Unique: -ZZNCN8XMM6nynCX0IEQpg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 38CCE106F8DB; Fri, 6 Aug 2021 13:29:39 +0000 (UTC) Received: from localhost (unknown [10.33.36.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id B95D15D6B1; Fri, 6 Aug 2021 13:29:38 +0000 (UTC) Date: Fri, 6 Aug 2021 14:29:37 +0100 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [committed] libstdc++: Move attributes that follow requires-clauses [PR101782] Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="G32Y+5D9BgzkRtPh" Content-Disposition: inline X-Spam-Status: No, score=-14.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, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Aug 2021 13:29:44 -0000 --G32Y+5D9BgzkRtPh Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline On 05/08/21 19:02 +0100, Jonathan Wakely wrote: >On 05/08/21 15:40 +0100, Jonathan Wakely wrote: >>On 05/08/21 15:19 +0100, Jonathan Wakely wrote: >>>On 04/08/21 12:55 +0100, Jonathan Wakely wrote: >>>>This adds [[nodiscard]] throughout , as proposed by P2377R0 >>>>(with some minor corrections). >>>> >>>>The attribute is added for all modes from C++11 up, using >>>>[[__nodiscard__]] or _GLIBCXX_NODISCARD where C++17 [[nodiscard]] can't >>>>be used directly. >>> >>>This change causes errors when -fconcepts-ts is used. Fixed like so. >>> >>>Tested powerpc64le-linux, committed to trunk. >>> >> >>>commit 7b1de3eb9ed3f8dde54732d88520292c5ad1157d >>>Author: Jonathan Wakely >>>Date: Thu Aug 5 13:34:00 2021 >>> >>> libstdc++: Move attributes that follow requires-clauses [PR101782] >>> As explained in the PR, the grammar in the Concepts TS means that a [ >>> token following a requires-clause is parsed as part of the >>> logical-or-expression rather than the start of an attribute. That makes >>> the following ill-formed when using -fconcepts-ts: >>> template requires foo [[nodiscard]] int f(T); >>> This change moves all attributes that follow a requires-clause to the >>> end of the function declarator. >> >> >>Except that as Jakub pointed out, putting it there doesn't work. >> >>It needs to be: >> >> template requires foo int f [[nodiscard]] (T); >> >>At least the testsuite isn't failing now, but the attributes I moved >>have no effect. I'll fix it ... some time. > >This should be correct now. Except I needed to move the ones I added to as well. Tested powerpc64le-linux, pushed to trunk. --G32Y+5D9BgzkRtPh Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit c2a984a3570b908a44a35e43bb48f0a05196156a Author: Jonathan Wakely Date: Fri Aug 6 13:43:26 2021 libstdc++: Also move the [[nodiscard]] attributes in Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * libsupc++/compare (compare_three_way, strong_order) (weak_order, partial_order, compare_strong_order_fallback) (compare_weak_order_fallback, compare_partial_order_fallback): Move nodiscard attributes to correct location. diff --git a/libstdc++-v3/libsupc++/compare b/libstdc++-v3/libsupc++/compare index faeff641437..5aee89e3a6e 100644 --- a/libstdc++-v3/libsupc++/compare +++ b/libstdc++-v3/libsupc++/compare @@ -548,9 +548,8 @@ namespace std template requires three_way_comparable_with<_Tp, _Up> constexpr auto - operator()(_Tp&& __t, _Up&& __u) const + operator() [[nodiscard]] (_Tp&& __t, _Up&& __u) const noexcept(noexcept(std::declval<_Tp>() <=> std::declval<_Up>())) - [[nodiscard]] { if constexpr (__detail::__3way_builtin_ptr_cmp<_Tp, _Up>) { @@ -672,9 +671,8 @@ namespace std template _Up> requires __strongly_ordered<_Tp, _Up> constexpr strong_ordering - operator()(_Tp&& __e, _Up&& __f) const + operator() [[nodiscard]] (_Tp&& __e, _Up&& __f) const noexcept(_S_noexcept<_Tp, _Up>()) - [[nodiscard]] { /* FIXME: if constexpr (floating_point>) @@ -720,9 +718,8 @@ namespace std template _Up> requires __weakly_ordered<_Tp, _Up> constexpr weak_ordering - operator()(_Tp&& __e, _Up&& __f) const + operator() [[nodiscard]] (_Tp&& __e, _Up&& __f) const noexcept(_S_noexcept<_Tp, _Up>()) - [[nodiscard]] { if constexpr (floating_point>) return __cmp_cust::__fp_weak_ordering(__e, __f); @@ -766,9 +763,8 @@ namespace std template _Up> requires __partially_ordered<_Tp, _Up> constexpr partial_ordering - operator()(_Tp&& __e, _Up&& __f) const + operator() [[nodiscard]] (_Tp&& __e, _Up&& __f) const noexcept(_S_noexcept<_Tp, _Up>()) - [[nodiscard]] { if constexpr (__adl_partial<_Tp, _Up>) return partial_ordering(partial_order(static_cast<_Tp&&>(__e), @@ -808,9 +804,8 @@ namespace std template _Up> requires __strongly_ordered<_Tp, _Up> || __op_eq_lt<_Tp, _Up> constexpr strong_ordering - operator()(_Tp&& __e, _Up&& __f) const + operator() [[nodiscard]] (_Tp&& __e, _Up&& __f) const noexcept(_S_noexcept<_Tp, _Up>()) - [[nodiscard]] { if constexpr (__strongly_ordered<_Tp, _Up>) return _Strong_order{}(static_cast<_Tp&&>(__e), @@ -841,9 +836,8 @@ namespace std template _Up> requires __weakly_ordered<_Tp, _Up> || __op_eq_lt<_Tp, _Up> constexpr weak_ordering - operator()(_Tp&& __e, _Up&& __f) const + operator() [[nodiscard]] (_Tp&& __e, _Up&& __f) const noexcept(_S_noexcept<_Tp, _Up>()) - [[nodiscard]] { if constexpr (__weakly_ordered<_Tp, _Up>) return _Weak_order{}(static_cast<_Tp&&>(__e), @@ -884,9 +878,8 @@ namespace std template _Up> requires __partially_ordered<_Tp, _Up> || __op_eq_lt_lt<_Tp, _Up> constexpr partial_ordering - operator()(_Tp&& __e, _Up&& __f) const + operator() [[nodiscard]] (_Tp&& __e, _Up&& __f) const noexcept(_S_noexcept<_Tp, _Up>()) - [[nodiscard]] { if constexpr (__partially_ordered<_Tp, _Up>) return _Partial_order{}(static_cast<_Tp&&>(__e), --G32Y+5D9BgzkRtPh--