public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-9548] c++: base template friend [PR52625]
@ 2021-05-21 14:50 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2021-05-21 14:50 UTC (permalink / raw)
To: gcc-cvs
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;
+};
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-21 14:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21 14:50 [gcc r9-9548] c++: base template friend [PR52625] Jason Merrill
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).