Fortran : ICE in gfc_conv_scalarized_array_ref PR53298

When an array of characters is an argument to a subroutine and
is accessed using (:)(1:) an ICE occurs.  The upper bound of the
substring does not have an expression and such should not have
a Scalarization State structure added to the Scalarization State
chain.

2020-07-29  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/fortran/

	PR fortran/53298
	* trans-array.c (gfc_walk_array_ref): If ref->ss.end is set
	call gfc_get_scalar_ss.

2020-07-29  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/testsuite/

	PR fortran/53298
	* gfortran.dg/pr53298.f90: New test.
This commit is contained in:
Mark Eggleston 2020-07-17 14:22:48 +01:00
parent 12324b9a93
commit c2e99836a2
2 changed files with 16 additions and 1 deletions

View File

@ -10800,7 +10800,8 @@ gfc_walk_array_ref (gfc_ss * ss, gfc_expr * expr, gfc_ref * ref)
if (ref->type == REF_SUBSTRING)
{
ss = gfc_get_scalar_ss (ss, ref->u.ss.start);
ss = gfc_get_scalar_ss (ss, ref->u.ss.end);
if (ref->u.ss.end)
ss = gfc_get_scalar_ss (ss, ref->u.ss.end);
}
/* We're only interested in array sections from now on. */

View File

@ -0,0 +1,14 @@
! { dg-do run }
program test
character(len=5) :: str(3)
str = ["abcde", "12345", "ABCDE" ]
call f(str(:))
contains
subroutine f(x)
character(len=*) :: x(:)
write(*,*) x(:)(1:)
end subroutine f
end program test
! { dg-output "abcde12345ABCDE" }