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 | |
parent | 9ba66bf5b9c69e0e2bcd1b2ab88160bf9b2aa417 (diff) |
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')
-rw-r--r-- | libgfortran/ChangeLog | 8 | ||||
-rw-r--r-- | libgfortran/runtime/ISO_Fortran_binding.c | 37 |
2 files changed, 25 insertions, 20 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 642134883db..c2031cfdafd 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2019-10-31 Tobias Burnus <tobias@codesourcery.com> + + PR fortran/92284. + * runtime/ISO_Fortran_binding.c (gfc_desc_to_cfi_desc): + 2019-10-19 Paul Thomas <pault@gcc.gnu.org> PR fortran/91926 @@ -7,8 +12,7 @@ 2019-10-08 Thomas Schwinge <thomas@codesourcery.com> PR fortran/68401 - * runtime/minimal.c (os_error_at): New function. - + * runtime/minimal.c (os_error_at): New function. * runtime/minimal.c: Revise. 2019-10-05 Paul Thomas <pault@gcc.gnu.org> diff --git a/libgfortran/runtime/ISO_Fortran_binding.c b/libgfortran/runtime/ISO_Fortran_binding.c index 695ef57ac32..c71d8e89453 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; |