[Patch, fortran] [4/4] gfc_ss structs initialization small refactoring: minor cleanups

Mikael Morin mikael.morin@sfr.fr
Wed Aug 31 20:37:00 GMT 2011


Now that array gfc_ss structs are initialized right after allocation,
especially their DIM and DIMEN fields are set properly, later initializations
of those fields are now redundant.

This patch removes such initializations and/or replaces them with asserts that
the value is already correct.
OK?
-------------- next part --------------
2011-08-30  Mikael Morin  <mikael.morin@gcc.gnu.org>

	* trans-array.c (gfc_trans_constant_array_constructor): Remove
	superfluous initialisation of DIM field.
	(gfc_trans_array_constructor): Assert that DIMEN field is properly set.
	(gfc_conv_expr_descriptor): Ditto.
	* trans-expr.c (gfc_conv_procedure_call): Ditto.
-------------- next part --------------
commit 6513df3737d66218914900a23d6ad2c948a986c7
Author: Mikael Morin <mik@gimli.local>
Date:   Tue Jun 28 18:10:33 2011 +0200

    Transformation assignements en assertions
diff --git a/trans-array.c b/trans-array.c
index 80a6fe6..37cdeb5 100644
--- a/trans-array.c
+++ b/trans-array.c
@@ -1882,7 +1882,6 @@ gfc_trans_constant_array_constructor (gfc_loopinfo * loop,
       info->start[i] = gfc_index_zero_node;
       info->end[i] = gfc_index_zero_node;
       info->stride[i] = gfc_index_one_node;
-      info->dim[i] = i;
     }
 
   if (info->dimen > loop->temp_dim)
@@ -1961,7 +1960,7 @@ gfc_trans_array_constructor (gfc_loopinfo * loop, gfc_ss * ss, locus * where)
       first_len = true;
     }
 
-  ss->data.info.dimen = loop->dimen;
+  gcc_assert (ss->data.info.dimen == loop->dimen);
 
   c = ss->expr->value.constructor;
   if (ss->expr->ts.type == BT_CHARACTER)
@@ -5915,7 +5914,7 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss)
 				      loop.dimen);
 
       se->string_length = loop.temp_ss->string_length;
-      loop.temp_ss->data.temp.dimen = loop.dimen;
+      gcc_assert (loop.temp_ss->data.temp.dimen == loop.dimen);
       loop.temp_ss->data.temp.codimen = loop.codimen;
       gfc_add_ss_to_loop (&loop, loop.temp_ss);
     }
diff --git a/trans-expr.c b/trans-expr.c
index 6a33719..131927c 100644
--- a/trans-expr.c
+++ b/trans-expr.c
@@ -3576,7 +3576,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 
 	  /* Set the type of the array.  */
 	  tmp = gfc_typenode_for_spec (&comp->ts);
-	  info->dimen = se->loop->dimen;
+	  gcc_assert (info->dimen == se->loop->dimen);
 
 	  /* Evaluate the bounds of the result, if known.  */
 	  gfc_set_loop_bounds_from_array_spec (&mapping, se, comp->as);
@@ -3611,7 +3611,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 
 	  /* Set the type of the array.  */
 	  tmp = gfc_typenode_for_spec (&ts);
-	  info->dimen = se->loop->dimen;
+	  gcc_assert (info->dimen == se->loop->dimen);
 
 	  /* Evaluate the bounds of the result, if known.  */
 	  gfc_set_loop_bounds_from_array_spec (&mapping, se, sym->result->as);


More information about the Fortran mailing list