From: Steven G. Kargl Date: Mon, 26 Sep 2016 18:44:36 +0000 (+0000) Subject: re PR fortran/77420 (gfortran and equivalence produces internal compiler error) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a184e37f0c1e72404b92c1bef9aa812b75b16fd8;p=gcc.git re PR fortran/77420 (gfortran and equivalence produces internal compiler error) 2016-09-26 Steven G. Kargl PR fortran/77420 * trans-common.c: Handle array elements in equivalence when the lower and upper bounds of array spec are NULL. 2016-09-26 Steven G. Kargl PR fortran/77420 * gfortran.dg/pr77420_1.f90: New test. * gfortran.dg/pr77420_2.f90: Ditto. * gfortran.dg/pr77420_3.f90: New test. Requires ... * gfortran.dg/pr77420_4.f90: this file. From-SVN: r240506 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d721bdf9746..c6bc662202b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-09-26 Steven G. Kargl + + PR fortran/77420 + * trans-common.c: Handle array elements in equivalence when + the lower and upper bounds of array spec are NULL. + 2016-09-26 Paul Thomas PR fortran/48298 diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c index 20ec69eb570..ee12fa22dc0 100644 --- a/gcc/fortran/trans-common.c +++ b/gcc/fortran/trans-common.c @@ -805,13 +805,21 @@ element_number (gfc_array_ref *ar) if (ar->dimen_type[i] != DIMEN_ELEMENT) gfc_internal_error ("element_number(): Bad dimension type"); - mpz_sub (n, *get_mpz (ar->start[i]), *get_mpz (as->lower[i])); + if (as && as->lower[i]) + mpz_sub (n, *get_mpz (ar->start[i]), *get_mpz (as->lower[i])); + else + mpz_sub_ui (n, *get_mpz (ar->start[i]), 1); mpz_mul (n, n, multiplier); mpz_add (offset, offset, n); - mpz_sub (extent, *get_mpz (as->upper[i]), *get_mpz (as->lower[i])); - mpz_add_ui (extent, extent, 1); + if (as && as->upper[i] && as->lower[i]) + { + mpz_sub (extent, *get_mpz (as->upper[i]), *get_mpz (as->lower[i])); + mpz_add_ui (extent, extent, 1); + } + else + mpz_set_ui (extent, 0); if (mpz_sgn (extent) < 0) mpz_set_ui (extent, 0); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b9b09967675..446848f2760 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2016-09-26 Steven G. Kargl + + PR fortran/77420 + * gfortran.dg/pr77420_1.f90: New test. + * gfortran.dg/pr77420_2.f90: Ditto. + * gfortran.dg/pr77420_3.f90: New test. Requires ... + * gfortran.dg/pr77420_4.f90: this file. + 2016-09-26 Kugan Vivekanandarajah PR middle-end/77719 diff --git a/gcc/testsuite/gfortran.dg/pr77420_1.f90 b/gcc/testsuite/gfortran.dg/pr77420_1.f90 new file mode 100644 index 00000000000..7652d6950fa --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr77420_1.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +module test_equivalence + real, private :: array1(100) + real, private :: array2(100) + equivalence(array1(3),array2(3)) +end module test_equivalence + +module mymodule + use test_equivalence + real, dimension(:), allocatable :: array1 +end module mymodule + +program test + use mymodule +end program test diff --git a/gcc/testsuite/gfortran.dg/pr77420_2.f90 b/gcc/testsuite/gfortran.dg/pr77420_2.f90 new file mode 100644 index 00000000000..4826801a2dc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr77420_2.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +module test_equivalence + real, private :: array1(100) + real, private :: array2(100) + equivalence(array1,array2) +end module test_equivalence + +module mymodule + use test_equivalence + real, dimension(:), allocatable :: array1 +end module mymodule + +program test + use mymodule +end program test diff --git a/gcc/testsuite/gfortran.dg/pr77420_3.f90 b/gcc/testsuite/gfortran.dg/pr77420_3.f90 new file mode 100644 index 00000000000..cf95ac05f83 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr77420_3.f90 @@ -0,0 +1,9 @@ +! { dg-do link } +! { dg-additional-sources pr77420_4.f90 } +! +module h5global + implicit none + integer :: h5p_default_f, h5p_flags + equivalence(h5p_flags, h5p_default_f) +end module h5global +! { dg-final { cleanup-modules "h5global" } } diff --git a/gcc/testsuite/gfortran.dg/pr77420_4.f90 b/gcc/testsuite/gfortran.dg/pr77420_4.f90 new file mode 100644 index 00000000000..5eee0986b80 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr77420_4.f90 @@ -0,0 +1,8 @@ +! { dg-do compile { target { ! *-*-* } } } +! +program bug + use H5GLOBAL + implicit none + integer :: i + i=H5P_DEFAULT_F +end program bug