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]

[patch] cp/pt.c: VECify inline_parm_levels;


Hi,

Attached is a patch to VECify inline_parm_levels.

I am not 100% sure about one thing.  Does anybody change the contents
of inline_parm_levels during maybe_end_member_template_processing?  I
didn't this that was the case, so I went ahead and used VEC_pop.  See
the last hunk.  Could somebody confirm?

Other than that, this patch cleans up a few thing.

We don't need inline_parm_levels_used because it is basically
VARRAY_ACTIVE_SIZE (inline_parm_levels).  Since the VEC API knows a
vector's length, we don't need a separate variable for a length.

We don't need to call VARRAY_INT_INIT or VARRAY_GROW ourselves.
VEC_safe_push does those for us.

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

2005-05-06  Kazu Hirata  <kazu@cs.umass.edu>

	* pt.c (inline_parm_levels,
	maybe_begin_member_template_processing,
	maybe_end_member_template_processing): Use VEC instead of
	VARRAY.

Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.995
diff -u -d -p -r1.995 pt.c
--- cp/pt.c	5 May 2005 16:24:10 -0000	1.995
+++ cp/pt.c	5 May 2005 16:25:35 -0000
@@ -60,9 +60,11 @@ static GTY(()) tree last_pending_templat
 int processing_template_parmlist;
 static int template_header_count;
 
+DEF_VEC_P(int);
+DEF_VEC_ALLOC_P(int,gc);
+
 static GTY(()) tree saved_trees;
-static GTY(()) varray_type inline_parm_levels;
-static size_t inline_parm_levels_used;
+static GTY(()) VEC(int,gc) *inline_parm_levels;
 
 static GTY(()) tree current_tinst_level;
 
@@ -410,12 +412,7 @@ maybe_begin_member_template_processing (
 
   /* Remember how many levels of template parameters we pushed so that
      we can pop them later.  */
-  if (!inline_parm_levels)
-    VARRAY_INT_INIT (inline_parm_levels, 4, "inline_parm_levels");
-  if (inline_parm_levels_used == inline_parm_levels->num_elements)
-    VARRAY_GROW (inline_parm_levels, 2 * inline_parm_levels_used);
-  VARRAY_INT (inline_parm_levels, inline_parm_levels_used) = levels;
-  ++inline_parm_levels_used;
+  VEC_safe_push (int, gc, inline_parm_levels, levels);
 }
 
 /* Undo the effects of maybe_begin_member_template_processing.  */
@@ -424,14 +421,13 @@ void 
 maybe_end_member_template_processing (void)
 {
   int i;
+  int last;
 
-  if (!inline_parm_levels_used)
+  if (!VEC_length (int, inline_parm_levels))
     return;
 
-  --inline_parm_levels_used;
-  for (i = 0; 
-       i < VARRAY_INT (inline_parm_levels, inline_parm_levels_used);
-       ++i) 
+  last = VEC_pop (int, inline_parm_levels);
+  for (i = 0; i < last; ++i) 
     {
       --processing_template_decl;
       current_template_parms = TREE_CHAIN (current_template_parms);


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