From: Jason Merrill <jason@redhat.com>
To: Marek Polacek <polacek@redhat.com>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] c++: ->template and implicit typedef [PR104608]
Date: Mon, 28 Feb 2022 12:31:37 -0400 [thread overview]
Message-ID: <c24d7667-bfca-1f69-073d-a1c1aaafc542@redhat.com> (raw)
In-Reply-To: <20220222214617.1949703-1-polacek@redhat.com>
On 2/22/22 17:46, Marek Polacek wrote:
> Here we have a forward declaration of Parameter for which we create
> an implicit typedef, which is a TYPE_DECL. Then, when looking it up
> at template definition time, cp_parser_template_id gets (since r12-6754)
> this TYPE_DECL which it can't handle.
Hmm, getting that global TYPE_DECL from lookup seems like a bug; isn't
the lookup earlier in cp_parser_template_name in object scope?
> This patch defers lookup for implicit typedefs, a la r12-6879.
>
> Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?
>
> PR c++/104608
>
> gcc/cp/ChangeLog:
>
> * parser.cc (cp_parser_template_name): Repeat lookup of implicit
> typedef.
>
> gcc/testsuite/ChangeLog:
>
> * g++.dg/parse/template-keyword3.C: New test.
> ---
> gcc/cp/parser.cc | 3 ++-
> gcc/testsuite/g++.dg/parse/template-keyword3.C | 12 ++++++++++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/g++.dg/parse/template-keyword3.C
>
> diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
> index 03d99aba13e..5e89e3737b0 100644
> --- a/gcc/cp/parser.cc
> +++ b/gcc/cp/parser.cc
> @@ -18681,7 +18681,8 @@ cp_parser_template_name (cp_parser* parser,
> return error_mark_node;
> }
> else if ((!DECL_P (decl) && !is_overloaded_fn (decl))
> - || TREE_CODE (decl) == USING_DECL)
> + || TREE_CODE (decl) == USING_DECL
> + || DECL_IMPLICIT_TYPEDEF_P (decl))
> /* Repeat the lookup at instantiation time. */
> decl = identifier;
> }
> diff --git a/gcc/testsuite/g++.dg/parse/template-keyword3.C b/gcc/testsuite/g++.dg/parse/template-keyword3.C
> new file mode 100644
> index 00000000000..59fe0fc180b
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/parse/template-keyword3.C
> @@ -0,0 +1,12 @@
> +// PR c++/104608
> +
> +class Parameter;
> +template <typename R> class Function
> +: public R
> +{
> + Function();
> +};
> +template <typename R>
> +Function<R>::Function() {
> + this->template Parameter<R>();
> +}
>
> base-commit: bc66b471d16ef2fd8cb66fd1131b41f80ecb9961
next prev parent reply other threads:[~2022-02-28 16:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 21:46 Marek Polacek
2022-02-28 16:31 ` Jason Merrill [this message]
2022-03-01 21:12 ` [PATCH v2] " Marek Polacek
2022-03-10 4:14 ` 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=c24d7667-bfca-1f69-073d-a1c1aaafc542@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).