From 2208990515245daa0c65cd35851510ecd2d290cb Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Sun, 16 Nov 2008 12:11:53 +0000 Subject: [PATCH] re PR fortran/38119 (character ICE in gfc_trans_create_temp_array) 2008-11-16 Paul Thomas PR fortran/38119 * trans-array.c (gfc_trans_create_temp_array): Set the loop->from to zero and the renormalisation of loop->to for all dimensions. 2008-11-16 Paul Thomas PR fortran/38119 * gfortran.dg/array_temporaries_3.f90: New test. From-SVN: r141915 --- gcc/fortran/ChangeLog | 7 +++++ gcc/fortran/trans-array.c | 18 ++++------- gcc/testsuite/ChangeLog | 5 +++ .../gfortran.dg/array_temporaries_3.f90 | 31 +++++++++++++++++++ 4 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/array_temporaries_3.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ca9f86576b4..4e3ac606a49 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2008-11-16 Paul Thomas + + PR fortran/38119 + * trans-array.c (gfc_trans_create_temp_array): Set the + loop->from to zero and the renormalisation of loop->to for all + dimensions. + 2008-11-16 Paul Thomas PR fortran/37926 diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 9cede5cc84f..9c48c421465 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -644,18 +644,12 @@ gfc_trans_create_temp_array (stmtblock_t * pre, stmtblock_t * post, for (dim = 0; dim < info->dimen; dim++) { n = loop->order[dim]; - if (n < loop->temp_dim) - gcc_assert (integer_zerop (loop->from[n])); - else - { - /* Callee allocated arrays may not have a known bound yet. */ - if (loop->to[n]) - loop->to[n] = - gfc_evaluate_now (fold_build2 (MINUS_EXPR, - gfc_array_index_type, loop->to[n], - loop->from[n]), pre); - loop->from[n] = gfc_index_zero_node; - } + /* Callee allocated arrays may not have a known bound yet. */ + if (loop->to[n]) + loop->to[n] = gfc_evaluate_now (fold_build2 (MINUS_EXPR, + gfc_array_index_type, + loop->to[n], loop->from[n]), pre); + loop->from[n] = gfc_index_zero_node; info->delta[dim] = gfc_index_zero_node; info->start[dim] = gfc_index_zero_node; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b8310460246..3fc91620fa9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-11-16 Paul Thomas + + PR fortran/38119 + * gfortran.dg/array_temporaries_3.f90: New test. + 2008-11-15 Jerry DeLisle PR libfortran/37294 diff --git a/gcc/testsuite/gfortran.dg/array_temporaries_3.f90 b/gcc/testsuite/gfortran.dg/array_temporaries_3.f90 new file mode 100644 index 00000000000..929a4c08e6b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/array_temporaries_3.f90 @@ -0,0 +1,31 @@ +! { dg-do run } +! PR38119 - The scalarizer got the loop size wrong +! for the temporary coming from the call to 'same'. +! +! Contributed by Mikael Morin +! based on a program by Vivek Rao. +! +module bar + implicit none + character(len = 2) :: c(1) +contains + elemental function trim_append (xx,yy) result(xy) + character (len = *), intent(in) :: xx,yy + character (len = len (xx) + len (yy)) :: xy + xy = trim (xx) // trim (yy) + end function trim_append + function same(xx) result(yy) + character (len = *), intent(in) :: xx(:) + character (len = len (xx)) :: yy(size (xx)) + yy = xx + end function same + subroutine xmain() + c = trim_append(["a"],same(["b"])) ! The problem occurred here + end subroutine xmain +end module bar + use bar + call xmain + if (c(1) .ne. "ab") call abort +end +! { dg-final { cleanup-modules "bar" } } + -- 2.30.2