public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [committed] libstdc++: Move attributes that follow requires-clauses [PR101782]
Date: Fri, 6 Aug 2021 14:29:37 +0100	[thread overview]
Message-ID: <YQ05QemkXImHzkah@redhat.com> (raw)
In-Reply-To: <YQwnqPykYypmI45n@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1692 bytes --]

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 <iterator>, 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 <jwakely@redhat.com>
>>>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<typename T> requires foo<T> [[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<typename T> requires foo<T> 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 <compare> as well.

Tested powerpc64le-linux, pushed to trunk.



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 3707 bytes --]

commit c2a984a3570b908a44a35e43bb48f0a05196156a
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Aug 6 13:43:26 2021

    libstdc++: Also move the [[nodiscard]] attributes in <compare>
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    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<typename _Tp, typename _Up>
       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<typename _Tp, __decayed_same_as<_Tp> _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<decay_t<_Tp>>)
@@ -720,9 +718,8 @@ namespace std
       template<typename _Tp, __decayed_same_as<_Tp> _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<decay_t<_Tp>>)
 	    return __cmp_cust::__fp_weak_ordering(__e, __f);
@@ -766,9 +763,8 @@ namespace std
       template<typename _Tp, __decayed_same_as<_Tp> _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<typename _Tp, __decayed_same_as<_Tp> _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<typename _Tp, __decayed_same_as<_Tp> _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<typename _Tp, __decayed_same_as<_Tp> _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),

      reply	other threads:[~2021-08-06 13:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04 11:55 [committed 1/2] libstdc++: Add [[nodiscard]] to iterators and related utilities Jonathan Wakely
2021-08-04 11:56 ` [committed 2/2] libstdc++: Add [[nodiscard]] to sequence containers Jonathan Wakely
2021-08-04 12:00   ` Jonathan Wakely
2021-08-05 12:09     ` Christophe Lyon
2021-08-05 12:13       ` Ville Voutilainen
2021-08-05 14:21         ` Jonathan Wakely
2021-08-05 14:38     ` Jonathan Wakely
2021-08-05 14:19 ` [committed] libstdc++: Move attributes that follow requires-clauses [PR101782] Jonathan Wakely
2021-08-05 14:27   ` Ville Voutilainen
2021-08-05 14:40   ` Jonathan Wakely
2021-08-05 18:02     ` Jonathan Wakely
2021-08-06 13:29       ` Jonathan Wakely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YQ05QemkXImHzkah@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).