This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 15701


This patch fixes another problem with interaction between templates
and friends.

Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-05-31  Mark Mitchell  <mark@codesourcery.com>

	PR c++/15701
	* friend.c (add_friend): Do not try to perform access checks for
	functions from dependent classes.

2004-05-31  Mark Mitchell  <mark@codesourcery.com>

	PR c++/15701
	* g++.dg/template/friend29.C: New test.

Index: cp/friend.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/friend.c,v
retrieving revision 1.93.4.1
diff -c -5 -p -r1.93.4.1 friend.c
*** cp/friend.c	20 Mar 2004 00:13:14 -0000	1.93.4.1
--- cp/friend.c	31 May 2004 22:41:23 -0000
*************** add_friend (tree type, tree decl, bool c
*** 162,172 ****
  	}
        list = TREE_CHAIN (list);
      }
  
    if (DECL_CLASS_SCOPE_P (decl))
!     perform_or_defer_access_check (TYPE_BINFO (DECL_CONTEXT (decl)), decl);
  
    maybe_add_class_template_decl_list (type, decl, /*friend_p=*/1);
  
    DECL_FRIENDLIST (typedecl)
      = tree_cons (DECL_NAME (decl), build_tree_list (NULL_TREE, decl),
--- 162,176 ----
  	}
        list = TREE_CHAIN (list);
      }
  
    if (DECL_CLASS_SCOPE_P (decl))
!     {
!       tree class_binfo = TYPE_BINFO (DECL_CONTEXT (decl));
!       if (!uses_template_parms (BINFO_TYPE (class_binfo)))
! 	perform_or_defer_access_check (class_binfo, decl);
!     }
  
    maybe_add_class_template_decl_list (type, decl, /*friend_p=*/1);
  
    DECL_FRIENDLIST (typedecl)
      = tree_cons (DECL_NAME (decl), build_tree_list (NULL_TREE, decl),
Index: testsuite/g++.dg/template/friend29.C
===================================================================
RCS file: testsuite/g++.dg/template/friend29.C
diff -N testsuite/g++.dg/template/friend29.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/template/friend29.C	31 May 2004 22:41:26 -0000
***************
*** 0 ****
--- 1,11 ----
+ // PR c++/15701
+ 
+ template<template<int> class T> struct A : T<0>
+ {
+     void foo();
+     template<template<int> class U> friend void A<U>::foo();
+ };
+ 
+ template<int> struct B {};
+ 
+ A<B> a;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]