public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-9548] c++: base template friend [PR52625] Date: Fri, 21 May 2021 14:50:54 +0000 (GMT) [thread overview] Message-ID: <20210521145054.086C8384A00F@sourceware.org> (raw) https://gcc.gnu.org/g:5b4cb06374890f2a190c9a989b569a9a15388445 commit r9-9548-g5b4cb06374890f2a190c9a989b569a9a15388445 Author: Jason Merrill <jason@redhat.com> Date: Wed Apr 7 15:38:07 2021 -0400 c++: base template friend [PR52625] Here we were mistakenly treating the injected-class-name as a partial specialization. gcc/cp/ChangeLog: PR c++/52625 * pt.c (maybe_process_partial_specialization): Check DECL_SELF_REFERENCE_P. gcc/testsuite/ChangeLog: PR c++/52625 * g++.dg/template/friend70.C: New test. Diff: --- gcc/cp/pt.c | 4 ++++ gcc/testsuite/g++.dg/template/friend70.C | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d0bea4a5266..20bc198efac 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -969,6 +969,10 @@ maybe_process_partial_specialization (tree type) if (CLASS_TYPE_P (type) && CLASSTYPE_LAMBDA_EXPR (type)) return type; + /* An injected-class-name is not a specialization. */ + if (DECL_SELF_REFERENCE_P (TYPE_NAME (type))) + return type; + if (TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM) { error ("name of class shadows template template parameter %qD", diff --git a/gcc/testsuite/g++.dg/template/friend70.C b/gcc/testsuite/g++.dg/template/friend70.C new file mode 100644 index 00000000000..54965486f79 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend70.C @@ -0,0 +1,9 @@ +// PR c++/52625 + +template<class> +class base {}; + +class derived : public base<derived> +{ + template<class> friend class base; +};
reply other threads:[~2021-05-21 14:50 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210521145054.086C8384A00F@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).