[gcc(refs/users/mikael/heads/refactor_descriptor_v206.01)] fortran: array descriptor: Move scalar type extraction to callers [PR122521]

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

commit dd05ff13ae181a1ef9d780b2763dce5d0ed4eade
Author: Mikael Morin <[email protected]>
Date:   Thu Aug 6 11:17:12 2026 +0200

    fortran: array descriptor: Move scalar type extraction to callers [PR122521]
    
    The function gfc_get_scalar_to_descriptor_type only uses the TREE_TYPE()
    of its first argument.  Make the function take the type directly as
    argument, moving the TREE_TYPE() access to callers.
    
            PR fortran/122521
    
    gcc/fortran/ChangeLog:
    
            * trans-expr.cc (get_scalar_to_descriptor_type): Remove argument
            `scalar'; add argument `scalar_type'.  Replace `TREE_TYPE (scalar)'
            with `scalar_type'.
            (gfc_conv_scalar_to_descriptor, gfc_conv_derived_to_class,
            gfc_conv_class_to_class): Only pass the type as argument in callers.

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

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 3943d41c747a..d187fee78ecf 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -88,7 +88,7 @@ gfc_get_character_len_in_bytes (tree type)
    arrays.  */
 
 static tree
-get_scalar_to_descriptor_type (tree scalar, symbol_attribute attr)
+get_scalar_to_descriptor_type (tree scalar_type, symbol_attribute attr)
 {
   enum gfc_array_kind akind;
   tree *lbound = NULL, *ubound = NULL;
@@ -101,18 +101,17 @@ get_scalar_to_descriptor_type (tree scalar, symbol_attribute attr)
   else
     akind = GFC_ARRAY_ASSUMED_SHAPE_CONT;
 
-  if (POINTER_TYPE_P (TREE_TYPE (scalar)))
-    scalar = TREE_TYPE (scalar);
-  if (TYPE_LANG_SPECIFIC (TREE_TYPE (scalar)))
+  if (POINTER_TYPE_P (scalar_type))
+    scalar_type = TREE_TYPE (scalar_type);
+  if (TYPE_LANG_SPECIFIC (scalar_type))
     {
-      struct lang_type *lang_specific = TYPE_LANG_SPECIFIC (TREE_TYPE (scalar));
+      struct lang_type *lang_specific = TYPE_LANG_SPECIFIC (scalar_type);
       codim = lang_specific->corank;
       lbound = lang_specific->lbound;
       ubound = lang_specific->ubound;
     }
-  return gfc_get_array_type_bounds (TREE_TYPE (scalar), 0, codim, lbound,
-				    ubound, 1, akind,
-				    !(attr.pointer || attr.target));
+  return gfc_get_array_type_bounds (scalar_type, 0, codim, lbound, ubound, 1,
+				    akind, !(attr.pointer || attr.target));
 }
 
 tree
@@ -120,7 +119,7 @@ gfc_conv_scalar_to_descriptor (gfc_se *se, tree scalar, symbol_attribute attr)
 {
   tree desc, type, etype;
 
-  type = get_scalar_to_descriptor_type (scalar, attr);
+  type = get_scalar_to_descriptor_type (TREE_TYPE (scalar), attr);
   etype = TREE_TYPE (scalar);
   desc = gfc_create_var (type, "desc");
   DECL_ARTIFICIAL (desc) = 1;
@@ -962,7 +961,7 @@ gfc_conv_derived_to_class (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym,
 	  if (fsym->ts.u.derived->components->as)
 	    {
 	      tree type;
-	      type = get_scalar_to_descriptor_type (parmse->expr,
+	      type = get_scalar_to_descriptor_type (TREE_TYPE (parmse->expr),
 						    gfc_expr_attr (e));
 	      gfc_conv_descriptor_dtype_set (&parmse->pre, ctree,
 					     gfc_get_dtype (type));
@@ -1403,7 +1402,7 @@ gfc_conv_class_to_class (gfc_se *parmse, gfc_expr *e, gfc_typespec class_ts,
     {
       if (e->rank == 0)
 	{
-	  tree type = get_scalar_to_descriptor_type (parmse->expr,
+	  tree type = get_scalar_to_descriptor_type (TREE_TYPE (parmse->expr),
 						     gfc_expr_attr (e));
 	  gfc_conv_descriptor_dtype_set (&block, ctree,
 					 gfc_get_dtype (type));
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.