diff options
author | Tobias Burnus <burnus@gcc.gnu.org> | 2019-10-31 11:12:55 +0100 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2019-10-31 11:12:55 +0100 |
commit | fc5a970817ad432e06cf22613ac5bd3e85c0e081 (patch) | |
tree | 9c54878c62654d99053197728ae36370287bccb4 /libgfortran/runtime | |
parent | 9ba66bf5b9c69e0e2bcd1b2ab88160bf9b2aa417 (diff) | |
download | gcc-fc5a970817ad432e06cf22613ac5bd3e85c0e081.zip gcc-fc5a970817ad432e06cf22613ac5bd3e85c0e081.tar.gz gcc-fc5a970817ad432e06cf22613ac5bd3e85c0e081.tar.bz2 |
Fortran] PR92284 – gfc_desc_to_cfi_desc fixes
gcc/fortran/
PR fortran/92284.
* trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Free CFI descriptor
at the end; partial revised revert of Rev. 277502.
libgfortran/
PR fortran/92284.
* runtime/ISO_Fortran_binding.c (gfc_desc_to_cfi_desc):
gcc/testsuite/
PR fortran/92284.
* gfortran.dg/bind-c-intent-out.f90: Update expected dump;
extend comment.
* gfortran.dg/bind_c_array_params_3.f90: New.
* gfortran.dg/bind_c_array_params_3_aux.c: New.
From-SVN: r277663
Diffstat (limited to 'libgfortran/runtime')
-rw-r--r-- | libgfortran/runtime/ISO_Fortran_binding.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/libgfortran/runtime/ISO_Fortran_binding.c b/libgfortran/runtime/ISO_Fortran_binding.c index 695ef57..c71d8e8 100644 --- a/libgfortran/runtime/ISO_Fortran_binding.c +++ b/libgfortran/runtime/ISO_Fortran_binding.c @@ -119,24 +119,25 @@ gfc_desc_to_cfi_desc (CFI_cdesc_t **d_ptr, const gfc_array_void *s) d->type = (CFI_type_t)(d->type + ((CFI_type_t)d->elem_len << CFI_type_kind_shift)); - /* Full pointer or allocatable arrays retain their lower_bounds. */ - for (n = 0; n < GFC_DESCRIPTOR_RANK (s); n++) - { - if (d->attribute != CFI_attribute_other) - d->dim[n].lower_bound = (CFI_index_t)GFC_DESCRIPTOR_LBOUND(s, n); - else - d->dim[n].lower_bound = 0; - - /* Assumed size arrays have gfc ubound == 0 and CFI extent = -1. */ - if ((n == GFC_DESCRIPTOR_RANK (s) - 1) - && GFC_DESCRIPTOR_LBOUND(s, n) == 1 - && GFC_DESCRIPTOR_UBOUND(s, n) == 0) - d->dim[n].extent = -1; - else - d->dim[n].extent = (CFI_index_t)GFC_DESCRIPTOR_UBOUND(s, n) - - (CFI_index_t)GFC_DESCRIPTOR_LBOUND(s, n) + 1; - d->dim[n].sm = (CFI_index_t)(GFC_DESCRIPTOR_STRIDE(s, n) * s->span); - } + if (d->base_addr) + /* Full pointer or allocatable arrays retain their lower_bounds. */ + for (n = 0; n < GFC_DESCRIPTOR_RANK (s); n++) + { + if (d->attribute != CFI_attribute_other) + d->dim[n].lower_bound = (CFI_index_t)GFC_DESCRIPTOR_LBOUND(s, n); + else + d->dim[n].lower_bound = 0; + + /* Assumed size arrays have gfc ubound == 0 and CFI extent = -1. */ + if (n == GFC_DESCRIPTOR_RANK (s) - 1 + && GFC_DESCRIPTOR_LBOUND(s, n) == 1 + && GFC_DESCRIPTOR_UBOUND(s, n) == 0) + d->dim[n].extent = -1; + else + d->dim[n].extent = (CFI_index_t)GFC_DESCRIPTOR_UBOUND(s, n) + - (CFI_index_t)GFC_DESCRIPTOR_LBOUND(s, n) + 1; + d->dim[n].sm = (CFI_index_t)(GFC_DESCRIPTOR_STRIDE(s, n) * s->span); + } if (*d_ptr == NULL) *d_ptr = d; |