aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>2003-07-08 15:35:53 +0000
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>2003-07-08 15:35:53 +0000
commitc4d0910c846a89358e0ee6c6e89a66351adfab90 (patch)
tree8dcccbe28562c4c2e9eb425c5a552da0c76806b1
parentf5d1c3deeff9fc22e415894792b2cf1898354f0d (diff)
downloadgcc-c4d0910c846a89358e0ee6c6e89a66351adfab90.zip
gcc-c4d0910c846a89358e0ee6c6e89a66351adfab90.tar.gz
gcc-c4d0910c846a89358e0ee6c6e89a66351adfab90.tar.bz2
re PR c++/11030 (Cannot befriend a template specialization)
PR c++/11030 * pt.c (instantiate_class_template): Don't call xref_tag to inject name when the friend class is a specialization. * g++.dg/template/friend19.C: New test. From-SVN: r69088
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/friend19.C28
4 files changed, 41 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 888f031..ae4a83c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2003-07-08 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/11030
+ * pt.c (instantiate_class_template): Don't call xref_tag to
+ inject name when the friend class is a specialization.
+
2003-07-07 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (build_scoped_method_call): Remove.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 60383ef..abb51b2 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5429,6 +5429,8 @@ instantiate_class_template (tree type)
else if (uses_template_parms (friend_type))
new_friend_type = tsubst (friend_type, args,
tf_error | tf_warning, NULL_TREE);
+ else if (CLASSTYPE_USE_TEMPLATE (friend_type))
+ new_friend_type = friend_type;
else
{
tree ns = decl_namespace_context (TYPE_MAIN_DECL (friend_type));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 79d98c1..cbeea7e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2003-07-08 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/11030
+ * g++.dg/template/friend19.C: New test.
+
2003-07-08 Jakub Jelinek <jakub@redhat.com>
* g++.dg/opt/strength-reduce.C: New test.
diff --git a/gcc/testsuite/g++.dg/template/friend19.C b/gcc/testsuite/g++.dg/template/friend19.C
new file mode 100644
index 0000000..d515977
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/friend19.C
@@ -0,0 +1,28 @@
+// { dg-do compile }
+
+// Origin: Benjamin Li <benxbli@yahoo.com>
+
+// PR c++/11030: Template substition of friend class that is
+// a specialization.
+
+template <int S>
+struct A
+{
+ void func(void);
+};
+
+template <class T>
+class C
+{
+ static void private_func(void) {}
+public:
+ friend class A<512>;
+};
+
+template <int S>
+void A<S>::func(void)
+{
+ C<void>::private_func();
+}
+
+template class A<512>;