aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2008-11-16 12:11:53 +0000
committerPaul Thomas <pault@gcc.gnu.org>2008-11-16 12:11:53 +0000
commit2208990515245daa0c65cd35851510ecd2d290cb (patch)
treebaf9c59bdffc7add7fec67efdf7041d6091cc291
parentb800fd64b54018965f6953121b58673fcca08687 (diff)
downloadgcc-2208990515245daa0c65cd35851510ecd2d290cb.zip
gcc-2208990515245daa0c65cd35851510ecd2d290cb.tar.gz
gcc-2208990515245daa0c65cd35851510ecd2d290cb.tar.bz2
re PR fortran/38119 (character ICE in gfc_trans_create_temp_array)
2008-11-16 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-16 Paul Thomas <pault@gcc.gnu.org> PR fortran/38119 * gfortran.dg/array_temporaries_3.f90: New test. From-SVN: r141915
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/trans-array.c18
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/array_temporaries_3.f9031
4 files changed, 49 insertions, 12 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index ca9f865..4e3ac60 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,12 @@
2008-11-16 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-16 Paul Thomas <pault@gcc.gnu.org>
+
PR fortran/37926
* trans-expr.c (gfc_free_interface_mapping): Null sym->formal
(gfc_add_interface_mapping): Copy the pointer to the formal
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 9cede5c..9c48c42 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 b831046..3fc9162 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-11-16 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/38119
+ * gfortran.dg/array_temporaries_3.f90: New test.
+
2008-11-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>
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 0000000..929a4c0
--- /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 <mikael.morin@tele2.fr>
+! 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" } }
+