public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org, Patrick Palka <ppalka@redhat.com>
Subject: Re: [PATCH] c++: Error recovery in merge_default_template_args [PR108206]
Date: Wed, 4 Jan 2023 10:03:49 -0500	[thread overview]
Message-ID: <ba07c506-9d24-1beb-c2d0-519b2514e094@redhat.com> (raw)
In-Reply-To: <Y7VHqivJl6gu4GNA@tucnak>

On 1/4/23 04:32, Jakub Jelinek wrote:
> Hi!
> 
> We ICE on the following testcase during error recovery, both new_parm
> and old_parm are error_mark_node, the ICE is on
>            error ("redefinition of default argument for %q+#D", new_parm);
>            inform (DECL_SOURCE_LOCATION (old_parm),
>                    "original definition appeared here");
> where we don't print anything useful for new_parm and ICE trying to
> access DECL_SOURCE_LOCATION of old_parm.  I think we shouldn't diagnose
> anything when either of the parms is erroneous, GCC 11 before
> merge_default_template_args has been added was doing
>        if (TREE_VEC_ELT (tmpl_parms, i) == error_mark_node
>            || TREE_VEC_ELT (parms, i) == error_mark_node)
>          continue;
> 
>        tmpl_parm = TREE_VALUE (TREE_VEC_ELT (tmpl_parms, i));
>        if (error_operand_p (tmpl_parm))
>          return false;
> in redeclare_class_template.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

> 2023-01-04  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR c++/108206
> 	* decl.cc (merge_default_template_args): Return false if either
> 	new_parm or old_parm are erroneous.
> 
> 	* g++.dg/template/pr108206.C: New test.
> 
> --- gcc/cp/decl.cc.jj	2022-12-22 11:09:52.026181629 +0100
> +++ gcc/cp/decl.cc	2023-01-03 18:11:25.202223528 +0100
> @@ -1556,6 +1556,8 @@ merge_default_template_args (tree new_pa
>         tree old_parm = TREE_VALUE (TREE_VEC_ELT (old_parms, i));
>         tree& new_default = TREE_PURPOSE (TREE_VEC_ELT (new_parms, i));
>         tree& old_default = TREE_PURPOSE (TREE_VEC_ELT (old_parms, i));
> +      if (error_operand_p (new_parm) || error_operand_p (old_parm))
> +	return false;
>         if (new_default != NULL_TREE && old_default != NULL_TREE)
>   	{
>   	  auto_diagnostic_group d;
> --- gcc/testsuite/g++.dg/template/pr108206.C.jj	2023-01-03 18:14:18.768730450 +0100
> +++ gcc/testsuite/g++.dg/template/pr108206.C	2023-01-03 18:13:40.427281176 +0100
> @@ -0,0 +1,5 @@
> +// PR c++/108206
> +// { dg-do compile { target c++11 } }
> +
> +template <X x, typename T1> void foo (T1);	// { dg-error "'X' has not been declared" }
> +template <X x, typename T2> void foo (T2);	// { dg-error "'X' has not been declared" }
> 
> 	Jakub
> 


      reply	other threads:[~2023-01-04 15:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04  9:32 Jakub Jelinek
2023-01-04 15:03 ` 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=ba07c506-9d24-1beb-c2d0-519b2514e094@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=ppalka@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).