https://gcc.gnu.org/g:38d2587985495011fc91debb9a8e71bae22c7fc5

commit 38d2587985495011fc91debb9a8e71bae22c7fc5
Author: Mikael Morin <[email protected]>
Date:   Thu Aug 6 12:56:22 2026 +0200

    Refactoring gfc_set_descriptor_from_scalar

Diff:
---
 gcc/fortran/trans-descriptor.cc | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 5b3e1e8f527e..a0d7087048c0 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "trans-const.h"
 #include "trans-types.h"
 #include "trans-array.h"
+#include "trans-descriptor.h"
 
 
 /* Array descriptor low level access routines.
@@ -1020,6 +1021,8 @@ gfc_set_descriptor_from_scalar (stmtblock_t *block, tree 
descr,
   gfc_conv_descriptor_dtype_set (block, descr,
                                 gfc_get_dtype (type));
   gfc_copy_coarray_desc_part (block, descr, scalar);
+  if (!POINTER_TYPE_P (TREE_TYPE (scalar)))
+    scalar = gfc_build_addr_expr (NULL_TREE, scalar);
   if (cond_presence)
     scalar = build3_loc (input_location, COND_EXPR,
                         TREE_TYPE (scalar),
@@ -1051,16 +1054,9 @@ void
 gfc_set_descriptor_from_scalar_class (stmtblock_t *block, tree descr,
                                      tree scalar, gfc_expr *scalar_expr)
 {
-  tree type = gfc_get_scalar_to_descriptor_type (TREE_TYPE (scalar),
-                                                gfc_expr_attr (scalar_expr));
-  gfc_conv_descriptor_dtype_set (block, descr,
-                                gfc_get_dtype (type));
-
   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, descr, tmp);
+  gfc_set_descriptor_from_scalar (block, descr, tmp, scalar_expr, NULL_TREE,
+                                 NULL_TREE);
 }

Reply via email to