This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, fortran] PR38119 - [4.4 Regression] character ICE in gfc_trans_create_temp_array
- From: "Paul Richard Thomas" <paul dot richard dot thomas at gmail dot com>
- To: "Fortran List" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 15 Nov 2008 16:58:41 +0100
- Subject: [Patch, fortran] PR38119 - [4.4 Regression] character ICE in gfc_trans_create_temp_array
This is essentially the patch in comment #18 for PR31610:-)
Bootstraps and regtests on FC9/x86_ia64 - OK for trunk?
Paul
2008-11-15 Paul Thomas <pault@gcc.gnu.org>
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-15 Paul Thomas <pault@gcc.gnu.org>
PR fortran/38119
* gfortran.dg/array_temporaries_3.f90: New test.
Index: gcc/fortran/trans-array.c
===================================================================
--- gcc/fortran/trans-array.c (revision 141861)
+++ gcc/fortran/trans-array.c (working copy)
@@ -644,18 +644,12 @@
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;
Index: /svn/trunk/gcc/testsuite/gfortran.dg/array_temporaries_3.f90
===================================================================
--- /svn/trunk/gcc/testsuite/gfortran.dg/array_temporaries_3.f90 (revision 0)
+++ /svn/trunk/gcc/testsuite/gfortran.dg/array_temporaries_3.f90 (revision 0)
@@ -0,0 +1,30 @@
+! { dg-do run }
+! PR38119 - The scalarizer got the loop size wrong
+! for the temporary coming from the call to 'same'.
+!
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+!
+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" } }
+