This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[gfortran] Fix PR fortran/13105
- From: Paul Brook <paul at nowt dot org>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Mon, 24 Nov 2003 22:31:29 +0000
- Subject: [gfortran] Fix PR fortran/13105
Patch below fixes PR fortran/13105.
This consist of two similar but unrelated cases where we didn't handle array
sections with elemental components correctly.
Tested on i686-linux.
Applied to tree-ssa branch.
Paul
2003-11-24 Paul Brook <paul@nowt.org>
PR fortran/13105
* array.c (gfc_array_ref_shape): Handle elemental dimensions.
* trans-array.c (gfc_trans_preloop_setup): Use correct dim lookup.
diff -uprxCVS clean/tree-ssa/gcc/fortran/array.c gcc/gcc/fortran/array.c
--- clean/tree-ssa/gcc/fortran/array.c
+++ gcc/gcc/fortran/array.c
@@ -1913,6 +1913,7 @@ try
gfc_array_ref_shape (gfc_array_ref * ar, mpz_t * shape)
{
int d;
+ int i;
d = 0;
@@ -1926,9 +1927,15 @@ gfc_array_ref_shape (gfc_array_ref * ar,
return SUCCESS;
case AR_SECTION:
- for (; d < ar->dimen; d++)
- if (ref_dimen_size (ar, d, &shape[d]) == FAILURE)
- goto cleanup;
+ for (i = 0; i < ar->dimen; i++)
+ {
+ if (ar->dimen_type[i] != DIMEN_ELEMENT)
+ {
+ if (ref_dimen_size (ar, i, &shape[d]) == FAILURE)
+ goto cleanup;
+ d++;
+ }
+ }
return SUCCESS;
diff -uprxCVS clean/tree-ssa/gcc/fortran/trans-array.c gcc/gcc/fortran/
trans-array.c
--- clean/tree-ssa/gcc/fortran/trans-array.c
+++ gcc/gcc/fortran/trans-array.c
@@ -1629,7 +1629,7 @@ gfc_trans_preloop_setup (gfc_loopinfo *
gfc_init_se (&se, NULL);
se.loop = loop;
se.expr = info->descriptor;
- stride = gfc_conv_array_stride (info->descriptor, i);
+ stride = gfc_conv_array_stride (info->descriptor, info->dim[i]);
index = gfc_conv_array_index_offset (&se, info, info->dim[i], i,
ar, stride);
gfc_add_block_to_block (pblock, &se.pre);