This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for templates/friends
- To: egcs-patches at egcs dot cygnus dot com
- Subject: C++ PATCH for templates/friends
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Thu, 25 Mar 1999 13:31:19 -0800
- Reply-to: mark at codesourcery dot com
This patch fixes an oversight in my recent patch fixing problems with
protected member access.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
1999-03-25 Mark Mitchell <mark@codesourcery.com>
* pt.c (tsubst_decl): Tsubst into DECL_BEFRIENDING_CLASSES.
Index: testsuite/g++.old-deja/g++.pt/friend40.C
===================================================================
RCS file: friend40.C
diff -N friend40.C
*** /dev/null Sat Dec 5 20:30:03 1998
--- friend40.C Thu Mar 25 13:24:52 1999
***************
*** 0 ****
--- 1,11 ----
+ // Build don't link:
+ // Origin: Jason Merrill <jason@cygnus.com>
+
+ template<class T> struct A
+ {
+ friend void f ();
+ };
+
+ A<short> a;
+ A<int> b;
+
Index: cp/pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.273
diff -c -p -r1.273 pt.c
*** pt.c 1999/03/24 01:10:09 1.273
--- pt.c 1999/03/25 21:24:57
*************** tsubst_decl (t, args, type, in_decl)
*** 5470,5475 ****
--- 5470,5476 ----
{
tree ctx;
tree argvec = NULL_TREE;
+ tree *friends;
tree gen_tmpl;
int member;
int args_depth;
*************** tsubst_decl (t, args, type, in_decl)
*** 5667,5672 ****
--- 5668,5684 ----
&& (IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (r))
== NULL_TREE))
SET_IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (r), r);
+ }
+
+ /* Copy the list of befriending classes. */
+ for (friends = &DECL_BEFRIENDING_CLASSES (r);
+ *friends;
+ friends = &TREE_CHAIN (*friends))
+ {
+ *friends = copy_node (*friends);
+ TREE_VALUE (*friends) = tsubst (TREE_VALUE (*friends),
+ args, /*complain=*/1,
+ in_decl);
}
if (DECL_CONSTRUCTOR_P (r))