From: Mark Eggleston Date: Thu, 2 Apr 2020 06:18:52 +0000 (+0100) Subject: fortran: ICE equivalence with an element of an array PR94030 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bf1f6d8819ade074271df718f01fd3a5a9dc1b82;p=gcc.git fortran: ICE equivalence with an element of an array PR94030 Deferred size arrays can not be used in equivalance statements. gcc/fortran/ChangeLog: PR fortran/94030 * resolve.c (resolve_equivalence): Correct formatting around the label "identical_types". Instead of using gfc_resolve_array_spec use is_non_constants_shape_array to determine whether the array can be used in a in an equivalence statement. gcc/testsuite/ChangeLog: PR fortran/94030 * gfortran.dg/pr94030_1.f90 * gfortran.dg/pr94030_2.f90 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2539e51861e..1aa71d8778e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2020-04-02 Steven G. Kargl + + PR fortran/94030 + * resolve.c (resolve_equivalence): Correct formatting + around the label "identical_types". Instead of using + gfc_resolve_array_spec use is_non_constants_shape_array + to determine whether the array can be used in a in an + equivalence statement. + 2020-04-01 Mark Eggleston PR fortran/94386 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index b6277d236da..79b0d724565 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -16873,7 +16873,8 @@ resolve_equivalence (gfc_equiv *eq) && !gfc_notify_std (GFC_STD_GNU, msg, sym->name, &e->where)) continue; - identical_types: +identical_types: + last_ts =&sym->ts; last_where = &e->where; @@ -16881,8 +16882,7 @@ resolve_equivalence (gfc_equiv *eq) continue; /* Shall not be an automatic array. */ - if (e->ref->type == REF_ARRAY - && !gfc_resolve_array_spec (e->ref->u.ar.as, 1)) + if (e->ref->type == REF_ARRAY && is_non_constant_shape_array (sym)) { gfc_error ("Array %qs at %L with non-constant bounds cannot be " "an EQUIVALENCE object", sym->name, &e->where); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ff021ac7787..2a686d23ee6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2020-04-02 Mark Eggleston + Steven G. Kargl + + PR fortran/94030 + * gfortran.dg/pr94030_1.f90: New test. + * gfortran.dg/pr94030_2.f90: New test. + 2020-04-01 Iain Buclaw PR d/94315 diff --git a/gcc/testsuite/gfortran.dg/pr94030_1.f90 b/gcc/testsuite/gfortran.dg/pr94030_1.f90 new file mode 100644 index 00000000000..e63d3cc8da4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr94030_1.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! + +subroutine f(n) + integer :: n + integer :: arr(n) + integer :: i + equivalence (i, arr(1)) +end + +! { dg-error "Array 'arr' at .1. with non-constant bounds cannot be an EQUIVALENCE object" " " { target *-*-* } 8 } diff --git a/gcc/testsuite/gfortran.dg/pr94030_2.f90 b/gcc/testsuite/gfortran.dg/pr94030_2.f90 new file mode 100644 index 00000000000..84bfdeaa819 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr94030_2.f90 @@ -0,0 +1,33 @@ +! { dg-do compile } +! +! Provided by Steve Kargl. + +subroutine foo(n,m) + integer, intent(in) :: n, m + integer a(n) + real b(n) + equivalence(a,b) + if (m /= 2) then + a = 1 + print *, a(1) + else + b = 42. + print *, b(1) + end if +end subroutine + +subroutine bar(m) + integer, intent(in) :: m + integer x(8) + real y(8) + equivalence(x,y) + if (m /= 2) then + x = 1 + print *, x(1) + else + y = 42. + print *, y(1) + end if +end subroutine + +! { dg-error "Array '.' at .1. with non-constant bounds cannot be an EQUIVALENCE object" " " { target *-*-* } 9 }