[gcc(refs/users/mikael/heads/refactor_descriptor_v206.01)] fortran: array descriptor: Factor scalar descriptor init 2/2 [PR122521]

Mikael Morin via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:a32f829e18c0edb716e4be4db787258c414b55cf

commit a32f829e18c0edb716e4be4db787258c414b55cf
Author: Mikael Morin <[email protected]>
Date:   Tue Aug 18 14:37:48 2026 +0200

    fortran: array descriptor: Factor scalar descriptor init 2/2 [PR122521]
    
    Fortran-tested on aarch64-unknown-linux-gnu.  OK for mainline?
    
    -- >8 --
    
    The previous changes brought to gfc_set_descriptor_from_scalar removed the
    main differences preventing them to be merged together.  Now we are left
    with two overloads having similar code, the second one being a simplified
    version of the first.  Forward the former to the latter.
    
            PR fortran/122521
    
    gcc/fortran/ChangeLog:
    
            * trans-descriptor.cc (gfc_set_descriptor_from_scalar): Forward
            to the other overload instead of using a simplified inline copy of
            its code.

Diff:
---
 gcc/fortran/trans-descriptor.cc | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index a838a98af6ae..8f0ee7c58f47 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -871,6 +871,8 @@ gfc_set_descriptor_from_scalar (stmtblock_t *block, tree descr, tree scalar,
   gfc_conv_descriptor_dtype_set (block, descr,
 				 gfc_get_dtype_rank_type (0, etype));
   gfc_copy_coarray_desc_part (block, descr, scalar);
+  if (!POINTER_TYPE_P (scalar_type))
+    scalar = gfc_build_addr_expr (NULL_TREE, scalar);
   if (cond_presence)
     scalar = build3_loc (input_location, COND_EXPR,
 			 TREE_TYPE (scalar),
@@ -889,13 +891,7 @@ gfc_set_descriptor_from_scalar (stmtblock_t *block, tree descr, tree scalar,
 void
 gfc_set_descriptor_from_scalar (stmtblock_t *block, tree descr, tree scalar)
 {
-  tree etype = TREE_TYPE (scalar);
-  if (!POINTER_TYPE_P (TREE_TYPE (scalar)))
-    scalar = gfc_build_addr_expr (NULL_TREE, scalar);
-
-  gfc_conv_descriptor_dtype_set (block, descr,
-				 gfc_get_dtype_rank_type (0, etype));
-  gfc_conv_descriptor_data_set (block, descr, scalar);
+  gfc_set_descriptor_from_scalar (block, descr, scalar, NULL_TREE, NULL_TREE);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.