From f9235a2bafb1ea078367b1b804fd73d5d849fcdc Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Sat, 30 Nov 2019 15:02:50 +0000 Subject: [PATCH] Do not look at _data component in gfc_dep_resolver. 2019-11-30 Thomas Koenig PR fortran/91783 * dependency.c (gfc_dep_resolver): Do not look at _data component if present. 2019-11-30 Thomas Koenig PR fortran/91783 * gfortran.dg/dependency_56.f90: New test. From-SVN: r278873 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/dependency.c | 12 ++++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/dependency_56.f90 | 14 ++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/dependency_56.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b2673866bee..a29d4229c7e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-11-30 Thomas Koenig + + PR fortran/91783 + * dependency.c (gfc_dep_resolver): Do not look at _data + component if present. + 2019-11-28 Jerry DeLisle PR fortran/90374 diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c index 51148709766..02e4b4f7a65 100644 --- a/gcc/fortran/dependency.c +++ b/gcc/fortran/dependency.c @@ -2098,6 +2098,18 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse, 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. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ad1be1daaed..650866f58c8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-30 Thomas Koenig + + PR fortran/91783 + * gfortran.dg/dependency_56.f90: New test. + 2019-11-29 Richard Biener PR tree-optimization/91003 diff --git a/gcc/testsuite/gfortran.dg/dependency_56.f90 b/gcc/testsuite/gfortran.dg/dependency_56.f90 new file mode 100644 index 00000000000..97c0c814aed --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dependency_56.f90 @@ -0,0 +1,14 @@ +! { 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 -- 2.30.2