From: Marek Polacek <polacek@redhat.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>
Subject: Re: [PATCH] c++: ICE with erroneous template redeclaration [PR106311]
Date: Fri, 22 Jul 2022 08:35:53 -0400 [thread overview]
Message-ID: <YtqZqZT0SIez7GLF@redhat.com> (raw)
In-Reply-To: <20220715152920.693196-1-polacek@redhat.com>
Ping.
On Fri, Jul 15, 2022 at 11:29:20AM -0400, Marek Polacek via Gcc-patches wrote:
> Here we ICE trying to get DECL_SOURCE_LOCATION of the parm that happens
> to be error_mark_node in this ill-formed test. I kept running into this
> while reducing code, so it'd be good to have it fixed.
>
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
>
> PR c++/106311
>
> gcc/cp/ChangeLog:
>
> * pt.cc (redeclare_class_template): Check DECL_P before accessing
> DECL_SOURCE_LOCATION.
>
> gcc/testsuite/ChangeLog:
>
> * g++.dg/template/redecl5.C: New test.
> ---
> gcc/cp/pt.cc | 3 ++-
> gcc/testsuite/g++.dg/template/redecl5.C | 5 +++++
> 2 files changed, 7 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/g++.dg/template/redecl5.C
>
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index 718dfa5bfa8..0a294e91a79 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -6377,7 +6377,8 @@ redeclare_class_template (tree type, tree parms, tree cons)
> {
> auto_diagnostic_group d;
> error ("template parameter %q+#D", tmpl_parm);
> - inform (DECL_SOURCE_LOCATION (parm), "redeclared here as %q#D", parm);
> + inform (DECL_P (parm) ? DECL_SOURCE_LOCATION (parm) : input_location,
> + "redeclared here as %q#D", parm);
> return false;
> }
>
> diff --git a/gcc/testsuite/g++.dg/template/redecl5.C b/gcc/testsuite/g++.dg/template/redecl5.C
> new file mode 100644
> index 00000000000..fb2d698e6bc
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/template/redecl5.C
> @@ -0,0 +1,5 @@
> +// PR c++/106311
> +// { dg-do compile }
> +
> +template <typename, long> struct array; // { dg-error "template parameter" }
> +template <typename, size_t X> struct array { }; // { dg-error "declared" }
>
> base-commit: 23dd41c480fa9f06c33c1e6090bbae53869f85af
> --
> 2.36.1
>
Marek
next prev parent reply other threads:[~2022-07-22 12:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-15 15:29 Marek Polacek
2022-07-22 12:35 ` Marek Polacek [this message]
2022-07-22 21:21 ` Jason Merrill
2022-07-25 18:43 ` [v2 PATCH] " Marek Polacek
2022-07-26 0:09 ` Jason Merrill
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=YtqZqZT0SIez7GLF@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).