friend.c (make_friend_class): Make sure a templated class is actually a template.

cp:
	* friend.c (make_friend_class): Make sure a templated class is
	actually a template.
testsuite:
	* g++.old-deja/g++.pt/friend47.C: New test.

From-SVN: r38939
This commit is contained in:
Nathan Sidwell 2001-01-12 09:13:16 +00:00 committed by Nathan Sidwell
parent 47d4f11635
commit a864166135
4 changed files with 46 additions and 25 deletions

View File

@ -1,3 +1,8 @@
2001-01-12 Nathan Sidwell <nathan@codesourcery.com>
* friend.c (make_friend_class): Make sure a templated class is
actually a template.
2001-01-11 Nathan Sidwell <nathan@codesourcery.com>
* decl2.c (get_guard): Set linkage from guarded decl.

View File

@ -225,32 +225,30 @@ make_friend_class (type, friend_type)
else
is_template_friend = 0;
if (is_template_friend
&& (TREE_CODE (friend_type) == TYPENAME_TYPE
|| TREE_CODE (friend_type) == TEMPLATE_TYPE_PARM))
/* [temp.friend]
A friend of a class or class template can be a function or
class template, a specialization of a function template or
class template, or an ordinary (nontemplate) function or
class. */
if (!is_template_friend)
;/* ok */
else if (TREE_CODE (friend_type) == TYPENAME_TYPE)
{
/* [temp.friend]
A friend of a class or class template can be a function or
class template, a specialization of a function template or
class template, or an ordinary (nontemplate) function or
class.
But, we're looking at something like:
template <class T> friend typename S<T>::X;
or:
template <class T> friend class T;
which isn't any of these. */
if (TREE_CODE (friend_type) == TYPENAME_TYPE)
cp_error ("typename type `%T' declared `friend'",
friend_type);
else
cp_error ("template parameter type `%T' declared `friend'",
friend_type);
/* template <class T> friend typename S<T>::X; */
cp_error ("typename type `%#T' declared `friend'", friend_type);
return;
}
else if (TREE_CODE (friend_type) == TEMPLATE_TYPE_PARM)
{
/* template <class T> friend class T; */
cp_error ("template parameter type `%T' declared `friend'", friend_type);
return;
}
else if (!CLASSTYPE_TEMPLATE_INFO (friend_type))
{
/* template <class T> friend class A; where A is not a template */
cp_error ("`%#T' is not a template", friend_type);
return;
}

View File

@ -1,3 +1,7 @@
2001-01-12 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.pt/friend47.C: New test.
2001-01-11 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.pt/instantiate13.C: New test.

View File

@ -0,0 +1,14 @@
// Build don't link:
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 7 Jan 2001 <nathan@codesourcery.com>
// Bug 1033. We ICE'd when trying to make a non template class a templated
// friend.
class A {};
class B {
template<class T> friend class A; // ERROR - not a template
};