From 974b8e618b52dd1d30ca067e75995fe9fc8e6895 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Wed, 12 Jun 2019 18:28:32 +0000 Subject: [PATCH] re PR fortran/90002 (ICE: free_expr0(): Bad expr type) 2019-06-12 Steven G. Kargl PR fortran/90002 * array.c (gfc_free_array_spec): When freeing an array-spec, avoid an ICE for assumed-shape coarrays 2019-06-12 Steven G. Kargl PR fortran/90002 * gfortran.dg/pr90002.f90: New test. From-SVN: r272201 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/array.c | 18 +++++++++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr90002.f90 | 6 ++++++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr90002.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 35e575a8d70..ee4dbea350e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-06-12 Steven G. Kargl + + PR fortran/90002 + * array.c (gfc_free_array_spec): When freeing an array-spec, avoid + an ICE for assumed-shape coarrays + 2019-06-08 Paul Thomas PR fortran/90786 diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c index 96732ecd2e8..0aee220e68d 100644 --- a/gcc/fortran/array.c +++ b/gcc/fortran/array.c @@ -324,10 +324,22 @@ gfc_free_array_spec (gfc_array_spec *as) if (as == NULL) return; - for (i = 0; i < as->rank + as->corank; i++) + if (as->corank == 0) { - gfc_free_expr (as->lower[i]); - gfc_free_expr (as->upper[i]); + for (i = 0; i < as->rank; i++) + { + gfc_free_expr (as->lower[i]); + gfc_free_expr (as->upper[i]); + } + } + else + { + int n = as->rank + as->corank - (as->cotype == AS_EXPLICIT ? 1 : 0); + for (i = 0; i < n; i++) + { + gfc_free_expr (as->lower[i]); + gfc_free_expr (as->upper[i]); + } } free (as); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d853d17a133..e5f1a56e6ff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-06-12 Steven G. Kargl + + PR fortran/90002 + * gfortran.dg/pr90002.f90: New test. + 2019-06-12 Martin Sebor PR middle-end/90676 diff --git a/gcc/testsuite/gfortran.dg/pr90002.f90 b/gcc/testsuite/gfortran.dg/pr90002.f90 new file mode 100644 index 00000000000..cb993a5d5cc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr90002.f90 @@ -0,0 +1,6 @@ +! { dg-do compile } +! { dg-options "-fcoarray=single" } +! Contributed by Arseny Solokha +module pc + integer, dimension(1) :: zw[1:1,1:*] +end module pc -- 2.30.2