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,committed] Fix PR7809


This is an updated version of the patch

    http://gcc.gnu.org/ml/gcc-patches/2003-06/msg01739.html

to take into account a recent change of access checking functions
to use BINFO node for context.  I just committed this as it is
really straightforward.  Tested on i686-pc-linux-gnu.

--Kriang


2003-07-17  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/7809
	* friend.c (add_friend): Check access for member functions
	and templates.

2003-07-17  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/7809
	* g++.dg/parse/access3.C: New test.


diff -cprN gcc-main-save/gcc/cp/friend.c gcc-main-new/gcc/cp/friend.c
*** gcc-main-save/gcc/cp/friend.c	Thu Jul 17 21:59:28 2003
--- gcc-main-new/gcc/cp/friend.c	Thu Jul 17 21:17:04 2003
*************** add_friend (tree type, tree decl)
*** 170,175 ****
--- 170,178 ----
        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)
diff -cprN gcc-main-save/gcc/testsuite/g++.dg/parse/access3.C gcc-main-new/gcc/testsuite/g++.dg/parse/access3.C
*** gcc-main-save/gcc/testsuite/g++.dg/parse/access3.C	Thu Jan  1 07:00:00 1970
--- gcc-main-new/gcc/testsuite/g++.dg/parse/access3.C	Thu Jul 17 21:15:14 2003
***************
*** 0 ****
--- 1,14 ----
+ // { dg-do compile }
+ 
+ // Origin: <bagnara@cs.unipr.it>
+ 
+ // PR c++/7809: Befriending inaccessible name.
+ 
+ class A {
+ private:
+   void f();		// { dg-error "private" }
+ };
+ 
+ class B {
+   friend void A::f();	// { dg-error "context" }
+ };


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