diff mbox series

[fortran] Fix PR 66089, ICE (plus wrong code) in dependency handling

Message ID 8e8f288d-a700-53c4-d1f6-cdea549374d0@netcologne.de
State New
Headers show
Series [fortran] Fix PR 66089, ICE (plus wrong code) in dependency handling | expand

Commit Message

Thomas Koenig March 6, 2019, 6:49 p.m. UTC
Hello world,

the attached patch fixes a 7/8/9 regression where dependency checking
was for class arrays and a scalar value was mishandled when the
dependency happened in an elemental function.

There was an ICE for the test case which is handled by
fixing up the class refs in gfc_walk_variable_expr.
Once this was gone, a wrong-code issue appeared which was fixed
by the part in gfc_scalar_elemental_arg_saved_as_reference
(is that the longest function name in gfortran?).

Regression-tested. OK for all affected branches?

Regards

	Thomas

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

	PR fortran/66089
	* trans-array.c (gfc_scalar_elemental_arg_saved_as_reference):
	Return false if a scalar tempoary is needed.
	(gfc_walk_variable_expr): Fix up class refs.

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

	PR fortran/66089
	* gfortran.dg/dependency_53.f90: New test.

Comments

Bernhard Reutner-Fischer March 8, 2019, 7:04 a.m. UTC | #1
On 6 March 2019 19:49:59 CET, Thomas Koenig <tkoenig@netcologne.de> wrote:
>Hello world,
>
>the attached patch fixes a 7/8/9 regression where dependency checking
>was for class arrays and a scalar value was mishandled when the
>dependency happened in an elemental function.
>
>There was an ICE for the test case which is handled by
>fixing up the class refs in gfc_walk_variable_expr.
>Once this was gone, a wrong-code issue appeared which was fixed
>by the part in gfc_scalar_elemental_arg_saved_as_reference
>(is that the longest function name in gfortran?).
>
>Regression-tested. OK for all affected branches?

Please change call abort to stop N in the test?

>	PR fortran/66089
>	* gfortran.dg/dependency_53.f90: New test.
Thomas Koenig March 8, 2019, 6 p.m. UTC | #2
Am 08.03.19 um 08:04 schrieb Bernhard Reutner-Fischer:
> Please change call abort to stop N in the test?

Done.

Anything else?  OK for trunk?

Regards

	Thomas
diff mbox series

Patch

Index: trans-array.c
===================================================================
--- trans-array.c	(Revision 269260)
+++ trans-array.c	(Arbeitskopie)
@@ -2699,6 +2699,9 @@  gfc_scalar_elemental_arg_saved_as_reference (gfc_s
   if (ss_info->type != GFC_SS_REFERENCE)
     return false;
 
+  if (ss_info->data.scalar.needs_temporary)
+    return false;
+
   /* If the actual argument can be absent (in other words, it can
      be a NULL reference), don't try to evaluate it; pass instead
      the reference directly.  */
@@ -10515,6 +10518,8 @@  gfc_walk_variable_expr (gfc_ss * ss, gfc_expr * ex
 {
   gfc_ref *ref;
 
+  gfc_fix_class_refs (expr);
+
   for (ref = expr->ref; ref; ref = ref->next)
     if (ref->type == REF_ARRAY && ref->u.ar.type != AR_ELEMENT)
       break;