re PR c++/8099 (Friend classes and template specializations)
PR c++/8099 * friend.c (make_friend_class): Allow partial specialization when declaration is not a template friend. * g++.dg/template/friend9.C: New test. From-SVN: r60308
This commit is contained in:
parent
cab7a9a3b9
commit
da9701a61c
@ -1,3 +1,9 @@
|
||||
2002-12-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
|
||||
|
||||
PR c++/8099
|
||||
* friend.c (make_friend_class): Allow partial specialization
|
||||
when declaration is not a template friend.
|
||||
|
||||
2002-12-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
|
||||
|
||||
PR c++/3663
|
||||
|
@ -205,12 +205,16 @@ make_friend_class (type, friend_type)
|
||||
return;
|
||||
}
|
||||
|
||||
if (processing_template_decl > template_class_depth (type))
|
||||
/* If the TYPE is a template then it makes sense for it to be
|
||||
friends with itself; this means that each instantiation is
|
||||
friends with all other instantiations. */
|
||||
{
|
||||
if (CLASS_TYPE_P (friend_type)
|
||||
&& CLASSTYPE_TEMPLATE_SPECIALIZATION (friend_type)
|
||||
&& uses_template_parms (friend_type))
|
||||
{
|
||||
/* [temp.friend]
|
||||
|
||||
Friend declarations shall not declare partial
|
||||
specializations. */
|
||||
error ("partial specialization `%T' declared `friend'",
|
||||
@ -218,11 +222,8 @@ make_friend_class (type, friend_type)
|
||||
return;
|
||||
}
|
||||
|
||||
if (processing_template_decl > template_class_depth (type))
|
||||
/* If the TYPE is a template then it makes sense for it to be
|
||||
friends with itself; this means that each instantiation is
|
||||
friends with all other instantiations. */
|
||||
is_template_friend = 1;
|
||||
}
|
||||
else if (same_type_p (type, friend_type))
|
||||
{
|
||||
pedwarn ("class `%T' is implicitly friends with itself",
|
||||
|
@ -1,3 +1,8 @@
|
||||
2002-12-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
|
||||
|
||||
PR c++/8099
|
||||
* g++.dg/template/friend9.C: New test.
|
||||
|
||||
2002-11-18 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
|
||||
|
||||
PR c++/3663
|
||||
|
18
gcc/testsuite/g++.dg/template/friend9.C
Normal file
18
gcc/testsuite/g++.dg/template/friend9.C
Normal file
@ -0,0 +1,18 @@
|
||||
// { dg-do compile }
|
||||
// Origin: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
|
||||
|
||||
// PR c++/8099
|
||||
// Partial specialization as friend class
|
||||
|
||||
template <int N, typename T> struct X;
|
||||
template <typename T> struct X<1,T>;
|
||||
|
||||
template <typename P> class Y {
|
||||
static int i;
|
||||
template <int N, typename T> friend struct X;
|
||||
friend struct X<1,P>;
|
||||
};
|
||||
|
||||
template <typename T> struct X<1,T> {
|
||||
X () { Y<T>::i; }; // access private field
|
||||
};
|
Loading…
Reference in New Issue
Block a user