https://gcc.gnu.org/g:2a6a2fae92b5cd3f8884cc054cc9cfd6aa3d6096
commit 2a6a2fae92b5cd3f8884cc054cc9cfd6aa3d6096 Author: Mikael Morin <mik...@gcc.gnu.org> Date: Sat Jul 19 15:55:19 2025 +0200 Modif gfc_init_descriptor_variable Diff: --- gcc/fortran/trans-descriptor.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc index f89ad587f62f..cc25347551a6 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -673,22 +673,28 @@ gfc_get_descriptor_offsets_for_info (const_tree desc_type, tree *data_off, void gfc_init_descriptor_variable (stmtblock_t *block, gfc_symbol *sym, tree descr) { + symbol_attribute attr = gfc_symbol_attr (sym); + /* NULLIFY the data pointer for non-saved allocatables, or for non-saved pointers when -fcheck=pointer is specified. */ - if (sym->attr.allocatable - || (sym->attr.pointer && (gfc_option.rtcheck & GFC_RTCHECK_POINTER))) + if (attr.allocatable + || (attr.pointer && (gfc_option.rtcheck & GFC_RTCHECK_POINTER))) { gfc_conv_descriptor_data_set (block, descr, null_pointer_node); - if (flag_coarray == GFC_FCOARRAY_LIB && sym->attr.codimension) + if (flag_coarray == GFC_FCOARRAY_LIB && attr.codimension) gfc_conv_descriptor_token_set (block, descr, null_pointer_node); } tree etype; - gcc_assert (sym->as && sym->as->rank>=0); + gfc_array_spec *as; + if (sym->ts.type == BT_CLASS) + as = CLASS_DATA (sym)->as; + else + as = sym->as; + + gcc_assert (as && as->rank >= 0); etype = gfc_get_element_type (TREE_TYPE (descr)); gfc_conv_descriptor_dtype_set (block, descr, - gfc_get_dtype_rank_type (sym->as->rank, - etype)); + gfc_get_dtype_rank_type (as->rank, etype)); } -