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
This commit is contained in:
Kriang Lerdsuwanakij 2003-07-08 15:35:53 +00:00 committed by Kriang Lerdsuwanakij
parent f5d1c3deef
commit c4d0910c84
4 changed files with 41 additions and 0 deletions

View 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.

View 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));

View 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.

View File

@ -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>;