Hello world,

this patch fixes a 10 regression in dependency checking. The
approach is simple - if gfc_dep_resolver is handed references
with _data, remove that.

Regression-tested. OK for trunk?

Regards

        Thomas

Do not look at _data component in gfc_dep_resolver.

2019-11-24  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/91783
        * dependency.c (gfc_dep_resolver): Do not look at _data
        component if present.

2019-11-24  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/91783
        * gfortran.dg/dependency_56.f90: New test.


Index: fortran/dependency.c
===================================================================
--- fortran/dependency.c	(Revision 278025)
+++ fortran/dependency.c	(Arbeitskopie)
@@ -2098,6 +2098,18 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gf
   gfc_dependency this_dep;
   bool same_component = false;
 
+  /* The refs might come in mixed, one with a _data component and one
+     without.  Look at their next reference in order to avoid an
+     ICE.  */
+
+  if (lref && lref->type == REF_COMPONENT && lref->u.c.component
+      && strcmp (lref->u.c.component->name, "_data") == 0)
+    lref = lref->next;
+
+  if (rref && rref->type == REF_COMPONENT && rref->u.c.component
+      && strcmp (rref->u.c.component->name, "_data") == 0)
+    rref = rref->next;
+
   this_dep = GFC_DEP_ERROR;
   fin_dep = GFC_DEP_ERROR;
   /* Dependencies due to pointers should already have been identified.
! { dg-do compile }
! PR 91783 - used to cause an ICE in dependency checking.
! Test case by Gerhard Steinmetz.
program p
   class(*), allocatable :: a(:)
   a = [1, 2, 3]
   a = f(a)
contains
   function f(x) result(y)
      class(*), allocatable, intent(in) :: x(:)
      class(*), allocatable :: y(:)
      y = x
   end
end

Reply via email to