https://gcc.gnu.org/g:c4bc5df18e6102645241397089c090117c7180b4
commit c4bc5df18e6102645241397089c090117c7180b4 Author: Mikael Morin <mik...@gcc.gnu.org> Date: Fri Jan 24 16:42:00 2025 +0100 Correction régression contiguous-2.f90 Diff: --- gcc/fortran/trans-decl.cc | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index 96a8e8ca10fd..19348c167388 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -7212,6 +7212,22 @@ gfc_conv_cfi_to_gfc (stmtblock_t *init, stmtblock_t *finally, else rank = build_int_cst (signed_char_type_node, sym->as->rank); + if (!GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (gfc_desc))) + { + tree offset, type; + type = TREE_TYPE (gfc_desc); + gfc_trans_array_bounds (type, sym, &offset, &block); + if (VAR_P (GFC_TYPE_ARRAY_OFFSET (type))) + gfc_add_modify (&block, GFC_TYPE_ARRAY_OFFSET (type), offset); + goto done; + } + + stmtblock_t block2; + gfc_init_block (&block2); + + gfc_set_gfc_from_cfi (&block, &block2, gfc_desc, cfi, rank, sym, + true, do_copy_inout, false); + /* With bind(C), the standard requires that both Fortran callers and callees handle noncontiguous arrays passed to an dummy with 'contiguous' attribute and with character(len=*) + assumed-size/explicit-size arrays. @@ -7371,22 +7387,6 @@ gfc_conv_cfi_to_gfc (stmtblock_t *init, stmtblock_t *finally, gfc_add_expr_to_block (&block, tmp); } - if (!GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (gfc_desc))) - { - tree offset, type; - type = TREE_TYPE (gfc_desc); - gfc_trans_array_bounds (type, sym, &offset, &block); - if (VAR_P (GFC_TYPE_ARRAY_OFFSET (type))) - gfc_add_modify (&block, GFC_TYPE_ARRAY_OFFSET (type), offset); - goto done; - } - - stmtblock_t block2; - gfc_init_block (&block2); - - gfc_set_gfc_from_cfi (&block, &block2, gfc_desc, cfi, rank, sym, - true, do_copy_inout, false); - if (sym->attr.allocatable || sym->attr.pointer) { tmp = gfc_get_cfi_desc_base_addr (cfi),