From: Marek Polacek <polacek@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v3] c++: Implement C++23 P2266R1, Simpler implicit move [PR101165]
Date: Tue, 27 Sep 2022 19:39:25 -0400 [thread overview]
Message-ID: <YzOJraytZZPJhmhJ@redhat.com> (raw)
In-Reply-To: <39fb63d9-8128-512b-523d-f575317cf7c2@redhat.com>
On Tue, Sep 27, 2022 at 05:44:12PM -0400, Jason Merrill wrote:
> On 9/27/22 16:26, Marek Polacek wrote:
> > --- a/gcc/cp/typeck.cc
> > +++ b/gcc/cp/typeck.cc
> > @@ -11042,8 +11042,13 @@ check_return_expr (tree retval, bool *no_warning)
> > the conditions for the named return value optimization. */
> > bool converted = false;
> > tree moved;
> > - /* This is only interesting for class type. */
> > - if (CLASS_TYPE_P (functype)
> > + /* Until C++23, this was only interesting for class type... */
> > + if ((CLASS_TYPE_P (functype)
> > + /* ...but in C++23, we should do the below when we're converting
> > + from/to a class/reference (a non-scalar type). */
> > + || (cxx_dialect >= cxx23
> > + && (!SCALAR_TYPE_P (functype)
> > + || !SCALAR_TYPE_P (TREE_TYPE (retval)))))
>
> You might reformat this as
> (cxx_dialect < cxx23
> ? CLASS...
> : (!SCALAR...
Done, I like that better.
> > --- a/gcc/testsuite/g++.dg/cpp0x/move-return3.C
> > +++ b/gcc/testsuite/g++.dg/cpp0x/move-return3.C
> > @@ -1,6 +1,7 @@
> > // PR c++/91212
> > // Test that C++11 implicit move semantics don't call the const copy.
> > -// { dg-do link }
> > +// In C++23, we call #2.
>
> I guess that behavior is tested by elision2.C:twelve()?
Yeah, I think that's exactly the same case.
> > --- a/gcc/testsuite/g++.old-deja/g++.mike/p2846b.C
> > +++ b/gcc/testsuite/g++.old-deja/g++.mike/p2846b.C
> > @@ -1,4 +1,4 @@
> > -// { dg-do run }
> > +// { dg-do run { target c++20_down } }
> > // Shows that problem of initializing one object's secondary base from
> > // another object via a user defined copy constructor for that base,
> > // the pointer for the secondary vtable is not set after implicit
> > @@ -11,6 +11,8 @@
> > // prms-id: 2846
> > +// This test fails in C++23 due to P2266.
>
> Instead of disabling this test for C++23, let's add a cast to B& in the
> return statement.
Fixed.
> OK with that change and optionally the ?: reformatting above.
Thanks a lot; patch pushed.
Marek
prev parent reply other threads:[~2022-09-27 23:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-03 16:42 [PATCH] " Marek Polacek
2022-09-07 2:38 ` Jason Merrill
2022-09-08 22:54 ` Marek Polacek
2022-09-12 20:27 ` Jason Merrill
2022-09-20 18:21 ` Marek Polacek
2022-09-20 18:19 ` [PATCH v2] " Marek Polacek
2022-09-26 17:29 ` Jason Merrill
2022-09-27 20:26 ` [PATCH v3] " Marek Polacek
2022-09-27 21:44 ` Jason Merrill
2022-09-27 23:39 ` Marek Polacek [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=YzOJraytZZPJhmhJ@redhat.com \
--to=polacek@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/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).