diff mbox series

[committed] Fix gcc-7 regression in front-end optimization

Message ID 867dff12-4f5f-0256-715b-08e74fb8dce5@netcologne.de
State New
Headers show
Series [committed] Fix gcc-7 regression in front-end optimization | expand

Commit Message

Thomas Koenig May 5, 2019, 2:05 p.m. UTC
Hello world,

I have just committed the attached patch as obvious after 
regresson-testing - it fixed a rare beast, a gcc 7.4-only regression.

I have also committed the test case to trunk, to make sure that
this does not re-break.  No real need to commit to the other
branches, I think.

Regards

	Thomas

2019-05-05  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/90344
	* frontend-passes.c (create_var): Bring into sync with gcc 8.

2019-05-05  Thomas Koenig <tkoenig@gcc.gnu.org>

	PR fortran/90344
	* gfortran.dg/pr90344.f90: New test.
diff mbox series

Patch

Index: frontend-passes.c
===================================================================
--- frontend-passes.c	(Revision 270881)
+++ frontend-passes.c	(Arbeitskopie)
@@ -701,6 +701,11 @@  create_var (gfc_expr * e, const char *vname)
   if (e->expr_type == EXPR_CONSTANT || is_fe_temp (e))
     return gfc_copy_expr (e);
 
+  /* Creation of an array of unknown size requires realloc on assignment.
+     If that is not possible, just return NULL.  */
+  if (flag_realloc_lhs == 0 && e->rank > 0 && e->shape == NULL)
+    return NULL;
+
   ns = insert_block ();
 
   if (vname)
@@ -748,7 +753,7 @@  create_var (gfc_expr * e, const char *vname)
     }
 
   deferred = 0;
-  if (e->ts.type == BT_CHARACTER && e->rank == 0)
+  if (e->ts.type == BT_CHARACTER)
     {
       gfc_expr *length;
 
@@ -759,6 +764,8 @@  create_var (gfc_expr * e, const char *vname)
       else
 	{
 	  symbol->attr.allocatable = 1;
+	  symbol->ts.u.cl->length = NULL;
+	  symbol->ts.deferred = 1;
 	  deferred = 1;
 	}
     }
@@ -771,7 +778,7 @@  create_var (gfc_expr * e, const char *vname)
 
   result = gfc_get_expr ();
   result->expr_type = EXPR_VARIABLE;
-  result->ts = e->ts;
+  result->ts = symbol->ts;
   result->ts.deferred = deferred;
   result->rank = e->rank;
   result->shape = gfc_copy_shape (e->shape, e->rank);