public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Marek Polacek <polacek@redhat.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] c++: ICE when xobj is not the first parm [PR113389]
Date: Wed, 17 Jan 2024 23:54:50 -0500	[thread overview]
Message-ID: <6ff234ab-44ef-4561-8443-e910e974ec9e@redhat.com> (raw)
In-Reply-To: <20240118011714.451164-1-polacek@redhat.com>

On 1/17/24 20:17, Marek Polacek wrote:
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

OK.

> -- >8 --
> In grokdeclarator/cdk_function the comment says that the find_xobj_parm
> lambda clears TREE_PURPOSE so that we can correctly detect an xobj that
> is not the first parameter.  That's all good, but we should also clear
> the TREE_PURPOSE once we've given the error, otherwise we crash later in
> check_default_argument because the 'this' TREE_PURPOSE lacks a type.
> 
> 	PR c++/113389
> 
> gcc/cp/ChangeLog:
> 
> 	* decl.cc (grokdeclarator) <case cdk_function>: Set TREE_PURPOSE to
> 	NULL_TREE when emitting an error.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/cpp23/explicit-obj-diagnostics10.C: New test.
> ---
>   gcc/cp/decl.cc                                          | 1 +
>   gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics10.C | 8 ++++++++
>   2 files changed, 9 insertions(+)
>   create mode 100644 gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics10.C
> 
> diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
> index 322e48dee2e..3e41fd4fa31 100644
> --- a/gcc/cp/decl.cc
> +++ b/gcc/cp/decl.cc
> @@ -13391,6 +13391,7 @@ grokdeclarator (const cp_declarator *declarator,
>   		  if (TREE_PURPOSE (parm) != this_identifier)
>   		    continue;
>   		  bad_xobj_parm_encountered = true;
> +		  TREE_PURPOSE (parm) = NULL_TREE;
>   		  gcc_rich_location bad_xobj_parm
>   		    (DECL_SOURCE_LOCATION (TREE_VALUE (parm)));
>   		  error_at (&bad_xobj_parm,
> diff --git a/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics10.C b/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics10.C
> new file mode 100644
> index 00000000000..354823db166
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp23/explicit-obj-diagnostics10.C
> @@ -0,0 +1,8 @@
> +// PR c++/113389
> +// { dg-do compile { target c++23 } }
> +
> +struct A {
> +  void foo(A, this A);	// { dg-error "only the first parameter" }
> +  void qux(A, this A,	// { dg-error "only the first parameter" }
> +	   this A);	// { dg-error "only the first parameter" }
> +};
> 
> base-commit: 4a8430c8c3abb1c2c14274105b3a621100f251a2


      reply	other threads:[~2024-01-18  4:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-18  1:17 Marek Polacek
2024-01-18  4:54 ` Jason Merrill [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=6ff234ab-44ef-4561-8443-e910e974ec9e@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=polacek@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).