https://gcc.gnu.org/g:12a0ff3fdcfc975d39dff11648b7c93ff5e58159
commit 12a0ff3fdcfc975d39dff11648b7c93ff5e58159 Author: Mikael Morin <[email protected]> Date: Sat Oct 11 14:10:00 2025 +0200 Correction partielle class_dummy_7.f90 Diff: --- gcc/fortran/trans-array.cc | 3 +++ gcc/fortran/trans-decl.cc | 2 ++ gcc/fortran/trans-descriptor.cc | 15 ++++++++++----- gcc/fortran/trans-types.cc | 26 +++++++++++++++----------- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index c3c2cfa8284a..ea0bb0c7eddf 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -6670,6 +6670,9 @@ gfc_trans_array_bounds (tree type, gfc_symbol * sym, tree * poffset, if (sym->ts.type == BT_CLASS) { tree class_descr = sym->backend_decl; + if (DECL_LANG_SPECIFIC (class_descr) + && GFC_DECL_SAVED_DESCRIPTOR (class_descr)) + class_descr = GFC_DECL_SAVED_DESCRIPTOR (class_descr); if (POINTER_TYPE_P (TREE_TYPE (class_descr))) class_descr = build_fold_indirect_ref_loc (input_location, class_descr); diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index 976a83822521..fe854c37bb5e 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -1323,6 +1323,8 @@ gfc_build_dummy_array_decl (gfc_symbol * sym, tree dummy) || (sym->attr.function && sym == sym->result)) && gfc_return_by_reference (sym)) packed = PACKED_NO; + else if (sym->ts.type == BT_CLASS) + packed = PACKED_NO; else if (as->type == AS_ASSUMED_SIZE) packed = PACKED_FULL; else if (as->type == AS_EXPLICIT) diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc index f6e79797de4a..ba8d73886027 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -2214,13 +2214,13 @@ gfc_set_descriptor (stmtblock_t *block, tree dest, tree src, gfc_expr *src_expr, int ndim = info->ref ? info->ref->u.ar.dimen : rank; /* Set the span field. */ - tree tmp = NULL_TREE; + tree span = NULL_TREE; if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (src))) - tmp = gfc_conv_descriptor_span_get (src); + span = gfc_conv_descriptor_span_get (src); else - tmp = gfc_get_array_span (src, src_expr); - if (tmp) - gfc_conv_descriptor_span_set (block, dest, tmp); + span = gfc_get_array_span (src, src_expr); + if (span) + gfc_conv_descriptor_span_set (block, dest, span); /* The following can be somewhat confusing. We have two descriptors, a new one and the original array. @@ -2269,11 +2269,16 @@ gfc_set_descriptor (stmtblock_t *block, tree dest, tree src, gfc_expr *src_expr, dtype = gfc_get_dtype (TREE_TYPE (dest)); gfc_conv_descriptor_dtype_set (block, dest, dtype); + if (src_expr->ts.type == BT_CLASS) + gfc_conv_descriptor_elem_len_set (block, dest, span); + /* The 1st element in the section. */ tree base = gfc_index_zero_node; if (src_expr->ts.type == BT_CHARACTER && src_expr->rank == 0 && corank) base = gfc_index_one_node; + tree tmp = NULL_TREE; + /* The offset from the 1st element in the section. */ tree offset = gfc_index_zero_node; diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc index 3facc134006a..05b8881cf004 100644 --- a/gcc/fortran/trans-types.cc +++ b/gcc/fortran/trans-types.cc @@ -1628,7 +1628,7 @@ gfc_is_nodesc_array (gfc_symbol * sym) static tree gfc_build_array_type (tree type, gfc_array_spec * as, enum gfc_array_kind akind, bool restricted, - bool contiguous, int codim) + bool contiguous, int codim, bool class_array = false) { tree lbound[GFC_MAX_DIMENSIONS]; tree ubound[GFC_MAX_DIMENSIONS]; @@ -1684,15 +1684,16 @@ gfc_build_array_type (tree type, gfc_array_spec * as, : GFC_ARRAY_ASSUMED_RANK; } - bool packed = contiguous - || as->type == AS_EXPLICIT - || as->type == AS_ASSUMED_SIZE - || akind == GFC_ARRAY_ALLOCATABLE - || akind == GFC_ARRAY_POINTER_CONT - || akind == GFC_ARRAY_ASSUMED_SHAPE_CONT - || akind == GFC_ARRAY_ASSUMED_RANK_ALLOCATABLE - || akind == GFC_ARRAY_ASSUMED_RANK_CONT - || akind == GFC_ARRAY_ASSUMED_RANK_POINTER_CONT; + bool packed = !class_array + && (contiguous + || as->type == AS_EXPLICIT + || as->type == AS_ASSUMED_SIZE + || akind == GFC_ARRAY_ALLOCATABLE + || akind == GFC_ARRAY_POINTER_CONT + || akind == GFC_ARRAY_ASSUMED_SHAPE_CONT + || akind == GFC_ARRAY_ASSUMED_RANK_ALLOCATABLE + || akind == GFC_ARRAY_ASSUMED_RANK_CONT + || akind == GFC_ARRAY_ASSUMED_RANK_POINTER_CONT); return gfc_get_array_type_bounds (type, as->rank == -1 ? GFC_MAX_DIMENSIONS : as->rank, corank, lbound, ubound, packed, akind, @@ -3091,7 +3092,10 @@ gfc_get_derived_type (gfc_symbol * derived, int codimen) ( field_type, c->as, akind, !c->attr.target && !c->attr.pointer, c->attr.contiguous, - c->attr.codimension || c->attr.pointer ? codimen : 0 + c->attr.codimension || c->attr.pointer ? codimen : 0, + derived->attr.is_class + && c == derived->components + && strcmp (c->name, "_data") == 0 ); } else
