https://gcc.gnu.org/g:bfc76a5de0c3c4649ef364f501f58d3350794c2a
commit bfc76a5de0c3c4649ef364f501f58d3350794c2a Author: Mikael Morin <mik...@gcc.gnu.org> Date: Thu Jul 31 20:35:45 2025 +0200 Extraction gfc_set_null_descriptor Correction régression null_actual_7 Diff: --- gcc/fortran/trans-descriptor.cc | 11 +++++++++++ gcc/fortran/trans-descriptor.h | 1 + gcc/fortran/trans-expr.cc | 27 ++++++++++++++++++++++----- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc index c60d9a5745bc..afbe09555002 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -776,3 +776,14 @@ gfc_nullify_descriptor (stmtblock_t *block, tree descr) gfc_conv_descriptor_data_set (block, descr, null_pointer_node); } + +void +gfc_set_descriptor_null (stmtblock_t *block, tree descr, tree etype, int rank) +{ + gfc_conv_descriptor_dtype_set (block, descr, + gfc_get_dtype_rank_type (rank, etype)); + gfc_conv_descriptor_span_set (block, descr, + gfc_conv_descriptor_elem_len_get (descr)); + gfc_conv_descriptor_data_set (block, descr, null_pointer_node); +} + diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h index 6fcf31fcdf58..893eaee126f9 100644 --- a/gcc/fortran/trans-descriptor.h +++ b/gcc/fortran/trans-descriptor.h @@ -99,5 +99,6 @@ void gfc_set_scalar_descriptor (stmtblock_t *, tree, tree); void gfc_nullify_descriptor (stmtblock_t *, gfc_expr *, tree, tree); /* Build a null array descriptor constructor. */ void gfc_nullify_descriptor (stmtblock_t *block, tree); +void gfc_set_descriptor_null (stmtblock_t *, tree, tree, int); #endif /* GFC_TRANS_DESCRIPTOR_H */ diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 3cad0a73527d..35f6ca562286 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -199,6 +199,26 @@ gfc_conv_scalar_to_descriptor (gfc_se *se, tree scalar, symbol_attribute attr) } +tree +gfc_conv_null_to_descriptor (gfc_se *se, tree etype, int rank) +{ + tree lbound[GFC_MAX_DIMENSIONS]; + tree ubound[GFC_MAX_DIMENSIONS]; + + memset (lbound, 0, sizeof (lbound)); + memset (ubound, 0, sizeof (ubound)); + + tree type = gfc_get_array_type_bounds (etype, rank, 0, lbound, ubound, 1, + GFC_ARRAY_POINTER_CONT, false); + tree desc = gfc_create_var (type, "desc"); + DECL_ARTIFICIAL (desc) = 1; + + gfc_set_descriptor_null (&se->pre, desc, etype, rank); + + return desc; +} + + /* Get the coarray token from the ultimate array or component ref. Returns a NULL_TREE, when the ref object is not allocatable or pointer. */ @@ -6705,11 +6725,8 @@ conv_null_actual (gfc_se * parmse, gfc_expr * e, gfc_symbol * fsym) For an assumed-rank dummy we provide a descriptor that passes the correct rank. */ { - tree tmp = parmse->expr; - - tmp = gfc_conv_scalar_to_descriptor (parmse, tmp, gfc_expr_attr (e)); - gfc_conv_descriptor_rank_set (&parmse->pre, tmp, e->rank); - gfc_conv_descriptor_data_set (&parmse->pre, tmp, null_pointer_node); + tree etype = gfc_typenode_for_spec (&e->ts); + tree tmp = gfc_conv_null_to_descriptor (parmse, etype, e->rank); parmse->expr = gfc_build_addr_expr (NULL_TREE, tmp); } else