re PR c++/11030 (Cannot befriend a template specialization)
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Tue, 8 Jul 2003 15:35:53 +0000 (15:35 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Tue, 8 Jul 2003 15:35:53 +0000 (15:35 +0000)
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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/friend19.C [new file with mode: 0644]

index 888f0310a7ebfb7c1cc9832aae50c56780bfd31b..ae4a83ce6f0f0bafe1343deaf540c697da47679e 100644 (file)
@@ -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.
index 60383ef914ab410881e739db2ed5767f9cb4856a..abb51b25b7d4992326db6686cfb154fe18b81163 100644 (file)
@@ -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));
index 79d98c1e9dbee18ff6e085b0cdd1a86694a496a2..cbeea7ef0bc7171afdd4e13f045d16c2d508182d 100644 (file)
@@ -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 (file)
index 0000000..d515977
--- /dev/null
@@ -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>;