From: Kriang Lerdsuwanakij Date: Tue, 8 Jul 2003 15:35:53 +0000 (+0000) Subject: re PR c++/11030 (Cannot befriend a template specialization) X-Git-Tag: releases/gcc-3.4.0~5047 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c4d0910c846a89358e0ee6c6e89a66351adfab90;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 888f0310a7eb..ae4a83ce6f0f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-07-08 Kriang Lerdsuwanakij + + 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 * cp-tree.h (build_scoped_method_call): Remove. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 60383ef914ab..abb51b25b7d4 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 79d98c1e9dbe..cbeea7ef0bc7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-07-08 Kriang Lerdsuwanakij + + PR c++/11030 + * g++.dg/template/friend19.C: New test. + 2003-07-08 Jakub Jelinek * 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 000000000000..d5159771ee54 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend19.C @@ -0,0 +1,28 @@ +// { dg-do compile } + +// Origin: Benjamin Li + +// PR c++/11030: Template substition of friend class that is +// a specialization. + +template +struct A +{ + void func(void); +}; + +template +class C +{ + static void private_func(void) {} +public: + friend class A<512>; +}; + +template +void A::func(void) +{ + C::private_func(); +} + +template class A<512>;