[gcc(refs/users/mikael/heads/refactor_descriptor_v206.01)] fortran: array descriptor: Remove redundant array type unwrapping [PR122521]

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

commit d4dd92e2d9902965095ee25871f2b377e72c64db
Author: Mikael Morin <[email protected]>
Date:   Tue Aug 11 18:34:44 2026 +0200

    fortran: array descriptor: Remove redundant array type unwrapping [PR122521]
    
    Fortran-tested on aarch64-unknown-linux-gnu.  OK for mainline?
    
    -- >8 --
    
    The function gfc_set_descriptor_from_scalar has this conditional:
    
      else if (TREE_TYPE (etype) && TREE_CODE (TREE_TYPE (etype)) == ARRAY_TYPE)
        etype = TREE_TYPE (etype);
    
    It unwraps any array from the element type before passing to the function
    gfc_get_dtype_rank_type.  The latter function unwraps array types similarly
    from its input, making the previous unwrapping redundant.  This change
    removes it.
    
    gcc/fortran/ChangeLog:
    
            * trans-descriptor.cc (gfc_set_descriptor_from_scalar): Pass element
            type to gfc_get_dtype_rank_type without redundantly unwrapping any
            array type from it.

Diff:
---
 gcc/fortran/trans-descriptor.cc | 2 --
 1 file changed, 2 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index e491a9ea1fac..e11bac4a9f65 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -893,8 +893,6 @@ 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);
-  else if (TREE_TYPE (etype) && TREE_CODE (TREE_TYPE (etype)) == ARRAY_TYPE)
-    etype = TREE_TYPE (etype);
 
   gfc_conv_descriptor_dtype_set (block, descr,
 				 gfc_get_dtype_rank_type (0, etype));
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.