summaryrefslogtreecommitdiffstats
path: root/gcc
diff options
context:
space:
mode:
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>2002-12-19 15:11:29 +0000
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>2002-12-19 15:11:29 +0000
commitcb96e388beb2e436f5eee1d569a68170a140e517 (patch)
tree4ea748acd4021885c21b5945f505825263b49d0d /gcc
parent0246130d5e09f0ecbe1be76c84444f22090ea387 (diff)
downloadppe42-gcc-cb96e388beb2e436f5eee1d569a68170a140e517.tar.gz
ppe42-gcc-cb96e388beb2e436f5eee1d569a68170a140e517.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@60308 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/friend.c29
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/friend9.C18
4 files changed, 44 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 042e0c0ed9d..1d7d395e344 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
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
* pt.c (lookup_template_class): Copy TREE_PRIVATE and
TREE_PROTECTED to created decl nodes.
diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c
index 9e474114312..050862d0151 100644
--- a/gcc/cp/friend.c
+++ b/gcc/cp/friend.c
@@ -205,24 +205,25 @@ make_friend_class (type, friend_type)
return;
}
- 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'",
- 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;
+ {
+ 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'",
+ friend_type);
+ return;
+ }
+
+ is_template_friend = 1;
+ }
else if (same_type_p (type, friend_type))
{
pedwarn ("class `%T' is implicitly friends with itself",
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a1510c04a33..d5f296f2d4a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/testsuite/g++.dg/template/friend9.C b/gcc/testsuite/g++.dg/template/friend9.C
new file mode 100644
index 00000000000..4464e5f8ee8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/friend9.C
@@ -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
+};
OpenPOWER on IntegriCloud