https://gcc.gnu.org/g:243347ea3599e0be1251f158b4a3e06831ed950e
commit 243347ea3599e0be1251f158b4a3e06831ed950e Author: Mikael Morin <mik...@gcc.gnu.org> Date: Wed Jan 29 20:33:12 2025 +0100 Correction régression pr49213.f90 Diff: --- gcc/fortran/trans-expr.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 7ff6a33e5e1b..d5bf453f61df 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -181,6 +181,16 @@ set_descriptor_from_scalar (stmtblock_t *block, tree desc, tree scalar, if (POINTER_TYPE_P (type)) type = TREE_TYPE (type); + tree etype = gfc_get_element_type (type); + tree dtype_val; + if (etype == void_type_node) + dtype_val = gfc_get_dtype_rank_type (0, TREE_TYPE (scalar)); + else + dtype_val = gfc_get_dtype (type); + + tree dtype_ref = gfc_conv_descriptor_dtype (desc); + gfc_add_modify (block, dtype_ref, dtype_val); + if (CONSTANT_CLASS_P (scalar)) { tree tmp; @@ -189,10 +199,6 @@ set_descriptor_from_scalar (stmtblock_t *block, tree desc, tree scalar, scalar = tmp; } - tree dtype_val = gfc_get_dtype (type); - tree dtype_ref = gfc_conv_descriptor_dtype (desc); - gfc_add_modify (block, dtype_ref, dtype_val); - tree tmp; if (is_class) tmp = gfc_class_data_get (scalar);