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:
parent
47d4f11635
commit
a864166135
|
@ -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>
|
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)
|
||||||
else
|
else
|
||||||
is_template_friend = 0;
|
is_template_friend = 0;
|
||||||
|
|
||||||
if (is_template_friend
|
|
||||||
&& (TREE_CODE (friend_type) == TYPENAME_TYPE
|
|
||||||
|| TREE_CODE (friend_type) == TEMPLATE_TYPE_PARM))
|
|
||||||
{
|
|
||||||
/* [temp.friend]
|
/* [temp.friend]
|
||||||
|
|
||||||
A friend of a class or class template can be a function or
|
A friend of a class or class template can be a function or
|
||||||
class template, a specialization of a function template or
|
class template, a specialization of a function template or
|
||||||
class template, or an ordinary (nontemplate) function or
|
class template, or an ordinary (nontemplate) function or
|
||||||
class.
|
class. */
|
||||||
|
if (!is_template_friend)
|
||||||
But, we're looking at something like:
|
;/* ok */
|
||||||
|
else if (TREE_CODE (friend_type) == TYPENAME_TYPE)
|
||||||
template <class T> friend typename S<T>::X;
|
{
|
||||||
|
/* template <class T> friend typename S<T>::X; */
|
||||||
or:
|
cp_error ("typename type `%#T' declared `friend'", friend_type);
|
||||||
|
return;
|
||||||
template <class T> friend class T;
|
}
|
||||||
|
else if (TREE_CODE (friend_type) == TEMPLATE_TYPE_PARM)
|
||||||
which isn't any of these. */
|
{
|
||||||
if (TREE_CODE (friend_type) == TYPENAME_TYPE)
|
/* template <class T> friend class T; */
|
||||||
cp_error ("typename type `%T' declared `friend'",
|
cp_error ("template parameter type `%T' declared `friend'", friend_type);
|
||||||
friend_type);
|
return;
|
||||||
else
|
}
|
||||||
cp_error ("template parameter type `%T' declared `friend'",
|
else if (!CLASSTYPE_TEMPLATE_INFO (friend_type))
|
||||||
friend_type);
|
{
|
||||||
|
/* template <class T> friend class A; where A is not a template */
|
||||||
|
cp_error ("`%#T' is not a template", friend_type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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>
|
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.
|
||||||
|
|
|
@ -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
|
||||||
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue