aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2021-06-22 12:42:17 -0700
committerSandra Loosemore <sandra@codesourcery.com>2021-06-23 17:59:46 -0700
commit1a2bbc08d9e5e4837d33afbb8c8347a182223a43 (patch)
tree5a7e08e1cb2900a05ea6faca4db1b8e40378d4ad /libgfortran
parentf754ef63b76885f4261d636d39b3ba66fc67537f (diff)
downloadgcc-1a2bbc08d9e5e4837d33afbb8c8347a182223a43.zip
gcc-1a2bbc08d9e5e4837d33afbb8c8347a182223a43.tar.gz
gcc-1a2bbc08d9e5e4837d33afbb8c8347a182223a43.tar.bz2
Fortran: fix sm computation in CFI_allocate [PR93524]
Backported from trunk. This patch fixes a bug in setting the step multiplier field in the C descriptor for array dimensions > 2. 2021-06-21 Sandra Loosemore <sandra@codesourcery.com> Tobias Burnus <tobias@codesourcery.com> libgfortran/ PR fortran/93524 * runtime/ISO_Fortran_binding.c (CFI_allocate): Fix sm computation. gcc/testsuite/ PR fortran/93524 * gfortran.dg/pr93524.c: New. * gfortran.dg/pr93524.f90: New.
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/runtime/ISO_Fortran_binding.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/libgfortran/runtime/ISO_Fortran_binding.c b/libgfortran/runtime/ISO_Fortran_binding.c
index 20833ad..0978832 100644
--- a/libgfortran/runtime/ISO_Fortran_binding.c
+++ b/libgfortran/runtime/ISO_Fortran_binding.c
@@ -254,10 +254,7 @@ CFI_allocate (CFI_cdesc_t *dv, const CFI_index_t lower_bounds[],
{
dv->dim[i].lower_bound = lower_bounds[i];
dv->dim[i].extent = upper_bounds[i] - dv->dim[i].lower_bound + 1;
- if (i == 0)
- dv->dim[i].sm = dv->elem_len;
- else
- dv->dim[i].sm = dv->elem_len * dv->dim[i - 1].extent;
+ dv->dim[i].sm = dv->elem_len * arr_len;
arr_len *= dv->dim[i].extent;
}
}