https://gcc.gnu.org/g:7e0c2d8802af3e3a04a44628da1e023727f11936

commit 7e0c2d8802af3e3a04a44628da1e023727f11936
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Tue Jan 28 22:03:00 2025 +0100

    Correction régression associate_66

Diff:
---
 gcc/fortran/trans-expr.cc | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 54f23a1d20c2..a22eceabbf36 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -178,8 +178,16 @@ set_descriptor_from_scalar (stmtblock_t *block, tree desc, 
tree scalar,
 {
   tree type = get_scalar_to_descriptor_type (scalar,
                                             gfc_expr_attr (scalar_expr));
-  gfc_add_modify (block, gfc_conv_descriptor_dtype (desc),
-                 gfc_get_dtype (type));
+  if (POINTER_TYPE_P (type))
+    type = TREE_TYPE (type);
+
+  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 = gfc_class_data_get (scalar);
+  if (!POINTER_TYPE_P (TREE_TYPE (tmp)))
+    tmp = gfc_build_addr_expr (NULL_TREE, tmp);
 
   gfc_conv_descriptor_data_set (block, desc, scalar);
 }
@@ -1447,13 +1455,7 @@ gfc_conv_class_to_class (gfc_se *parmse, gfc_expr *e, 
gfc_typespec class_ts,
       && e->rank != class_ts.u.derived->components->as->rank)
     {
       if (e->rank == 0)
-       {
-         tmp = gfc_class_data_get (parmse->expr);
-         if (!POINTER_TYPE_P (TREE_TYPE (tmp)))
-           tmp = gfc_build_addr_expr (NULL_TREE, tmp);
-
-         set_descriptor_from_scalar (&block, ctree, tmp, e);
-       }
+       set_descriptor_from_scalar (&block, ctree, parmse->expr, e);
       else
        gfc_class_array_data_assign (&block, ctree, parmse->expr, false);
     }

Reply via email to