[gomp] Fix PR fortran/15809 on the gomp branch

Jakub Jelinek jakub@redhat.com
Mon Dec 5 11:13:00 GMT 2005


Hi!

While the gfc_get_symbol_decl change is completely unnecessary
on the gomp branch, gfortran.dg/auto_char_dummy_array_1.f90
test was failing for other reason, GFC_TYPE_ARRAY_DATAPTR_TYPE
of the argument wasn't getting "gimplified" from within
gfc_trans_deferred_vars, so the parameter had a SAVE_EXPR
in GFC_TYPE_ARRAY_DATAPTR_TYPE of the parameter's type.
As the SAVE_EXPR was first used in an conditional block
and later on used in a different block, we could end up with
uninitialized temporary variable the SAVE_EXPR was gimplified
into.  Fixed thusly:

2005-12-05  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/15809
	* trans-decl.c (gfc_get_symbol_decl): Revert 2005-11-30 and
	2005-12-01 changes.
	(gfc_trans_vla_type_sizes): Also "gimplify"
	GFC_TYPE_ARRAY_DATAPTR_TYPE for GFC_DESCRIPTOR_TYPE_P types.
	* trans-array.c (gfc_trans_deferred_array): Call
	gfc_trans_vla_type_sizes.

--- gcc/fortran/trans-decl.c.jj	2005-12-04 21:27:19.000000000 +0100
+++ gcc/fortran/trans-decl.c	2005-12-05 11:09:49.000000000 +0100
@@ -841,9 +841,7 @@ tree
 gfc_get_symbol_decl (gfc_symbol * sym)
 {
   tree decl;
-  tree etype = NULL_TREE;
   tree length = NULL_TREE;
-  tree tmp = NULL_TREE;
   int byref;
 
   gcc_assert (sym->attr.referenced);
@@ -883,21 +881,6 @@ gfc_get_symbol_decl (gfc_symbol * sym)
 	      gfc_finish_var_decl (length, sym);
 	      gfc_defer_symbol_init (sym);
 	    }
-
-	  /* Set the element size of automatic and assumed character length
-	     length, dummy, pointer arrays.  */
-	  if (sym->attr.pointer && sym->attr.dummy
-		&& sym->attr.dimension)
-	    {
-	      tmp = gfc_build_indirect_ref (sym->backend_decl);
-	      etype = gfc_get_element_type (TREE_TYPE (tmp));
-	      if (TYPE_SIZE_UNIT (etype) == NULL_TREE)
-		{
-		  tmp = TYPE_SIZE_UNIT (gfc_character1_type_node);
-		  tmp = fold_convert (TREE_TYPE (tmp), sym->ts.cl->backend_decl);
-		  TYPE_SIZE_UNIT (etype) = tmp;
-		}
-	    }
 	}
 
       /* Use a copy of the descriptor for dummy arrays.  */
@@ -2436,6 +2419,16 @@ gfc_trans_vla_type_sizes (gfc_symbol *sy
   while (POINTER_TYPE_P (type))
     type = TREE_TYPE (type);
 
+  if (GFC_DESCRIPTOR_TYPE_P (type))
+    {
+      tree etype = GFC_TYPE_ARRAY_DATAPTR_TYPE (type);
+
+      while (POINTER_TYPE_P (etype))
+	etype = TREE_TYPE (etype);
+
+      gfc_trans_vla_type_sizes_1 (etype, body);
+    }
+
   gfc_trans_vla_type_sizes_1 (type, body);
 }
 
--- gcc/fortran/trans-array.c.jj	2005-12-05 10:32:26.000000000 +0100
+++ gcc/fortran/trans-array.c	2005-12-05 10:35:51.000000000 +0100
@@ -4200,7 +4200,10 @@ gfc_trans_deferred_array (gfc_symbol * s
 
   if (sym->ts.type == BT_CHARACTER
       && !INTEGER_CST_P (sym->ts.cl->backend_decl))
-    gfc_trans_init_string_length (sym->ts.cl, &fnblock);
+    {
+      gfc_trans_init_string_length (sym->ts.cl, &fnblock);
+      gfc_trans_vla_type_sizes (sym, &fnblock);
+    }
 
   /* Dummy and use associated variables don't need anything special.  */
   if (sym->attr.dummy || sym->attr.use_assoc)

	Jakub



More information about the Gcc-patches mailing list