[fortran] Fix the rest of PR 71203
diff mbox series

Message ID b056ded3-da56-469b-6f0c-7be8c8990c9b@tkoenig.net
State New
Headers show
Series
  • [fortran] Fix the rest of PR 71203
Related show

Commit Message

Thomas König March 9, 2019, 12:44 p.m. UTC
Hello world,

the attached patch fixes the rest of PR 71203 (i.e. the non-character
parts). I have checked in gdb that the shape set with this patch
does indeed not create a memory leak.

Regression-tested. OK for trunk?

(This makes three patches that are currently awaiting review, the
other two are https://gcc.gnu.org/ml/fortran/2019-03/msg00022.html
and https://gcc.gnu.org/ml/fortran/2019-02/msg00241.html.  I'd
appreciate somebody looking at these, I think I am close to the
limit of concurrent patches in my tree :-)

Regards

	Thomas

2019-03-09  Thomas König  <tkoenig@gcc.gnu.org>

	PR fortran/71203
	* decl.c (add_init_expr_to_sym):  Add shape if init has none.  Add
	assert that it has to be an EXPR_ARRAY in this case.

2019-03-09  Thomas König  <tkoenig@gcc.gnu.org>

	PR fortran/71203
	* gfortran.dg/array_simplify_3.f90: New test case.

Comments

Jerry DeLisle March 9, 2019, 2:06 p.m. UTC | #1
On 3/9/19 4:44 AM, Thomas König wrote:
> Hello world,
> 
> the attached patch fixes the rest of PR 71203 (i.e. the non-character
> parts). I have checked in gdb that the shape set with this patch
> does indeed not create a memory leak.
> 
> Regression-tested. OK for trunk?
> 
> (This makes three patches that are currently awaiting review, the
> other two are https://gcc.gnu.org/ml/fortran/2019-03/msg00022.html
> and https://gcc.gnu.org/ml/fortran/2019-02/msg00241.html.  I'd
> appreciate somebody looking at these, I think I am close to the
> limit of concurrent patches in my tree :-)
> 

This one looks good to go. Looking at the others.

Jerry

Patch
diff mbox series

Index: decl.c
===================================================================
--- decl.c	(Revision 269443)
+++ decl.c	(Arbeitskopie)
@@ -1983,8 +1983,14 @@  add_init_expr_to_sym (const char *name, gfc_expr *
 	      return false;
 	    }
 
-	  /* Shape should be present, we get an initialization expression.  */
-	  gcc_assert (init->shape);
+	  /* The shape may be NULL for EXPR_ARRAY, set it.  */
+	  if (init->shape == NULL)
+	    {
+	      gcc_assert (init->expr_type == EXPR_ARRAY);
+	      init->shape = gfc_get_shape (1);
+	      if (!gfc_array_size (init, &init->shape[0]))
+		  gfc_internal_error ("gfc_array_size failed");
+	    }
 
 	  for (dim = 0; dim < sym->as->rank; ++dim)
 	    {