OSDN Git Service

* trans.h (struct gfc_ss_info): New field refcount.
authormikael <mikael@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 Nov 2011 22:50:06 +0000 (22:50 +0000)
committermikael <mikael@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 Nov 2011 22:50:06 +0000 (22:50 +0000)
* trans-array.c (free_ss_info): Decrement refcount. Return early if
still non-zero.
(gfc_get_array_ss, gfc_get_temp_ss, gfc_get_scalar_ss): Increment
refcount.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180883 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/fortran/trans.h

index 9b07f76..d014b9d 100644 (file)
@@ -1,5 +1,13 @@
 2011-11-03  Mikael Morin  <mikael@gcc.gnu.org>
 
+       * trans.h (struct gfc_ss_info): New field refcount.
+       * trans-array.c (free_ss_info): Decrement refcount. Return early if
+       still non-zero.
+       (gfc_get_array_ss, gfc_get_temp_ss, gfc_get_scalar_ss): Increment
+       refcount.
+
+2011-11-03  Mikael Morin  <mikael@gcc.gnu.org>
+
        * trans-array.c (gfc_trans_create_temp_array): Move invariant condition
        out of the containing loop. 
 
index 663d12e..abb6db2 100644 (file)
@@ -489,6 +489,11 @@ gfc_free_ss_chain (gfc_ss * ss)
 static void
 free_ss_info (gfc_ss_info *ss_info)
 {
+  ss_info->refcount--;
+  if (ss_info->refcount > 0)
+    return;
+
+  gcc_assert (ss_info->refcount == 0);
   free (ss_info);
 }
 
@@ -532,6 +537,7 @@ gfc_get_array_ss (gfc_ss *next, gfc_expr *expr, int dimen, gfc_ss_type type)
   int i;
 
   ss_info = gfc_get_ss_info ();
+  ss_info->refcount++;
   ss_info->type = type;
   ss_info->expr = expr;
 
@@ -556,6 +562,7 @@ gfc_get_temp_ss (tree type, tree string_length, int dimen)
   int i;
 
   ss_info = gfc_get_ss_info ();
+  ss_info->refcount++;
   ss_info->type = GFC_SS_TEMP;
   ss_info->string_length = string_length;
   ss_info->data.temp.type = type;
@@ -580,6 +587,7 @@ gfc_get_scalar_ss (gfc_ss *next, gfc_expr *expr)
   gfc_ss_info *ss_info;
 
   ss_info = gfc_get_ss_info ();
+  ss_info->refcount++;
   ss_info->type = GFC_SS_SCALAR;
   ss_info->expr = expr;
 
index c35b1ae..02f2b42 100644 (file)
@@ -185,6 +185,7 @@ gfc_ss_type;
 
 typedef struct gfc_ss_info
 {
+  int refcount;
   gfc_ss_type type;
   gfc_expr *expr;
   tree string_length;