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]

C++ PATCH for access control



This patch fixes a small buglet in yesterday's changes, and add
assertions that should trap any similar failures.

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com

1999-03-10  Mark Mitchell  <mark@markmitchell.com>

	* search.c (dfs_canonical_queue): New function.
	(dfs_assert_unmarked_p): Likewise.
	(assert_canonical_unmarked): Likewise.
	(access_in_type): Use it.
	(accessible_p): Likewise.  Walk the whole tree when umarking.

Index: search.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/search.c,v
retrieving revision 1.83
diff -c -p -r1.83 search.c
*** search.c	1999/03/09 23:02:42	1.83
--- search.c	1999/03/10 18:32:04
*************** static tree dfs_accessible_queue_p PROTO
*** 144,149 ****
--- 144,152 ----
  static tree dfs_accessible_p PROTO ((tree, void *));
  static tree dfs_access_in_type PROTO ((tree, void *));
  static tree access_in_type PROTO ((tree, tree));
+ static tree dfs_canonical_queue PROTO ((tree, void *));
+ static tree dfs_assert_unmarked_P PROTO ((tree, void *));
+ static tree assert_canonical_unmarked PROTO ((tree));
  
  /* Allocate a level of searching.  */
  
*************** canonical_binfo (binfo)
*** 622,627 ****
--- 625,662 ----
  	  ? TYPE_BINFO (BINFO_TYPE (binfo)) : binfo);
  }
  
+ /* A queue function that simply ensures that we walk into the
+    canonical versions of virtual bases.  */
+ 
+ static tree
+ dfs_canonical_queue (binfo, data)
+      tree binfo;
+      void *data ATTRIBUTE_UNUSED;
+ {
+   return canonical_binfo (binfo);
+ }
+ 
+ /* Called via dfs_walk from assert_canonical_unmarked.  */
+ 
+ static tree
+ dfs_assert_unmarked_p (binfo, data)
+      tree binfo;
+      void *data ATTRIBUTE_UNUSED;
+ {
+   my_friendly_assert (!BINFO_MARKED (binfo), 0);
+   return NULL_TREE;
+ }
+ 
+ /* Asserts that all the nodes below BINFO (using the canonical
+    versions of virtual bases) are unmarked.  */
+ 
+ static void
+ assert_canonical_unmarked (binfo)
+      tree binfo;
+ {
+   dfs_walk (binfo, dfs_assert_unmarked_p, dfs_canonical_queue, 0);
+ }
+ 
  /* If BINFO is marked, return a canonical version of BINFO.
     Otherwise, return NULL_TREE.  */
  
*************** access_in_type (type, decl)
*** 762,767 ****
--- 797,803 ----
      each node with the most lenient access.  */
    dfs_walk_real (binfo, 0, dfs_access_in_type, shared_unmarked_p, decl);
    dfs_walk (binfo, dfs_unmark, shared_marked_p,  0);
+   assert_canonical_unmarked (binfo);
  
    return TREE_CHAIN (binfo);
  }
*************** accessible_p (type, decl)
*** 927,934 ****
    t = dfs_walk (binfo, dfs_accessible_p, 
  		dfs_accessible_queue_p,
  		protected_ok ? &protected_ok : 0);
!   /* Clear any mark bits.  */
!   dfs_walk (binfo, dfs_unmark, shared_marked_p,  0);
  
    return t != NULL_TREE;
  }
--- 963,973 ----
    t = dfs_walk (binfo, dfs_accessible_p, 
  		dfs_accessible_queue_p,
  		protected_ok ? &protected_ok : 0);
!   /* Clear any mark bits.  Note that we have to walk the whole tree
!      here, since we have aborted the previous walk from some point
!      deep in the tree.  */
!   dfs_walk (binfo, dfs_unmark, dfs_canonical_queue,  0);
!   assert_canonical_unmarked (binfo);
  
    return t != NULL_TREE;
  }


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