Commit a8641661 by Nathan Sidwell Committed by Nathan Sidwell

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
parent 47d4f116
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> 2001-01-11 Nathan Sidwell <nathan@codesourcery.com>
* decl2.c (get_guard): Set linkage from guarded decl. * decl2.c (get_guard): Set linkage from guarded decl.
......
...@@ -225,32 +225,30 @@ make_friend_class (type, friend_type) ...@@ -225,32 +225,30 @@ make_friend_class (type, friend_type)
else else
is_template_friend = 0; is_template_friend = 0;
if (is_template_friend /* [temp.friend]
&& (TREE_CODE (friend_type) == TYPENAME_TYPE
|| TREE_CODE (friend_type) == TEMPLATE_TYPE_PARM)) 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] /* template <class T> friend typename S<T>::X; */
cp_error ("typename type `%#T' declared `friend'", friend_type);
A friend of a class or class template can be a function or return;
class template, a specialization of a function template or }
class template, or an ordinary (nontemplate) function or else if (TREE_CODE (friend_type) == TEMPLATE_TYPE_PARM)
class. {
/* template <class T> friend class T; */
But, we're looking at something like: cp_error ("template parameter type `%T' declared `friend'", friend_type);
return;
template <class T> friend typename S<T>::X; }
else if (!CLASSTYPE_TEMPLATE_INFO (friend_type))
or: {
/* template <class T> friend class A; where A is not a template */
template <class T> friend class T; cp_error ("`%#T' is not a template", friend_type);
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);
return; return;
} }
......
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> 2001-01-11 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.pt/instantiate13.C: New test. * g++.old-deja/g++.pt/instantiate13.C: New test.
......
// 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
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment