https://gcc.gnu.org/g:ce8c179cb325ff5cd24526710af18670d20b87b4

commit ce8c179cb325ff5cd24526710af18670d20b87b4
Author: Mikael Morin <[email protected]>
Date:   Mon Oct 6 16:54:53 2025 +0200

    Correction régression class_array_23.f90

Diff:
---
 gcc/fortran/trans-array.cc      |  2 +-
 gcc/fortran/trans-array.h       |  3 ++-
 gcc/fortran/trans-descriptor.cc | 11 +++++++++--
 gcc/fortran/trans-descriptor.h  |  2 +-
 gcc/fortran/trans-stmt.cc       |  2 +-
 5 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 03d1336006b0..38d80de10d81 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -6115,7 +6115,7 @@ bool
 gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree status, tree errmsg,
                    tree errlen, tree label_finish, tree expr3_elem_size,
                    gfc_expr *expr3, tree e3_arr_desc, bool e3_has_nodescriptor,
-                   gfc_omp_namelist *omp_alloc, bool explicit_ts)
+                   gfc_omp_namelist *omp_alloc, gfc_typespec * explicit_ts)
 {
   tree tmp;
   tree pointer;
diff --git a/gcc/fortran/trans-array.h b/gcc/fortran/trans-array.h
index f055c58555d2..6f72de5a6e10 100644
--- a/gcc/fortran/trans-array.h
+++ b/gcc/fortran/trans-array.h
@@ -21,7 +21,8 @@ along with GCC; see the file COPYING3.  If not see
 /* Generate code to initialize and allocate an array.  Statements are added to
    se, which should contain an expression for the array descriptor.  */
 bool gfc_array_allocate (gfc_se *, gfc_expr *, tree, tree, tree, tree, tree,
-                        gfc_expr *, tree, bool, gfc_omp_namelist *, bool);
+                        gfc_expr *, tree, bool, gfc_omp_namelist *,
+                        gfc_typespec *);
 
 /* Allow the bounds of a loop to be set from a callee's array spec.  */
 void gfc_set_loop_bounds_from_array_spec (gfc_interface_mapping *,
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 223d7bb5e41d..4505f167f28f 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -3145,7 +3145,7 @@ gfc_descriptor_init_count (tree descriptor, int rank, int 
corank,
                           tree * overflow, tree expr3_elem_size,
                           gfc_expr *expr3, tree expr3_desc,
                           bool e3_has_nodescriptor, gfc_expr *expr,
-                          tree element_size, bool explicit_ts,
+                          tree element_size, gfc_typespec * explicit_ts,
                           tree *empty_array_cond)
 {
   tree type;
@@ -3205,10 +3205,17 @@ gfc_descriptor_init_count (tree descriptor, int rank, 
int corank,
   else if (expr3_desc && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (expr3_desc)))
     gfc_conv_descriptor_dtype_set (pblock, descriptor,
                                   gfc_conv_descriptor_dtype_get (expr3_desc));
-  else if (expr->ts.type == BT_CLASS && !explicit_ts
+  else if (expr->ts.type == BT_CLASS && explicit_ts->type == BT_UNKNOWN
           && expr3 && expr3->ts.type != BT_CLASS
           && expr3_elem_size != NULL_TREE && expr3_desc == NULL_TREE)
     gfc_conv_descriptor_elem_len_set (pblock, descriptor, expr3_elem_size);
+  else if (explicit_ts->type != BT_UNKNOWN)
+    {
+      tree elt_type = gfc_typenode_for_spec (explicit_ts);
+      tree dtype = gfc_get_dtype_rank_type (rank, elt_type,
+                                           bytes_counted_strides);
+      gfc_conv_descriptor_dtype_set (pblock, descriptor, dtype);
+    }
   else
     gfc_conv_descriptor_dtype_set (pblock, descriptor, gfc_get_dtype (type));
 
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 1b85e3004736..a91f42ed00fc 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -152,7 +152,7 @@ tree
 gfc_descriptor_init_count (tree, int, int, gfc_expr **, gfc_expr **,
                           stmtblock_t * pblock, stmtblock_t *, tree *,
                           tree, gfc_expr *, tree, bool, gfc_expr *, tree,
-                          bool, tree *);
+                          gfc_typespec *, tree *);
 void gfc_set_empty_descriptor_bounds (stmtblock_t *, tree, int);
 tree gfc_create_unallocated_library_result_descriptor (stmtblock_t *, tree,
                                                       tree);
diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc
index eb3b4438054c..fdeed942e234 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -7233,7 +7233,7 @@ gfc_trans_allocate (gfc_code * code, gfc_omp_namelist 
*omp_allocate)
                               tmp, e3rhs ? e3rhs : code->expr3,
                               e3_is == E3_DESC ? expr3 : NULL_TREE,
                               e3_has_nodescriptor, omp_alloc_item,
-                              code->ext.alloc.ts.type != BT_UNKNOWN))
+                              &code->ext.alloc.ts))
        {
          /* A scalar or derived type.  First compute the size to
             allocate.

Reply via email to