https://gcc.gnu.org/g:191318372a5204dad3bb637591b50363a61aaa42

commit 191318372a5204dad3bb637591b50363a61aaa42
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Fri Jul 18 11:42:38 2025 +0200

    Revert "Correction gfc_clear_descriptor assumed rank"
    
    This reverts commit 061babd52c7447e2a4be927fe4d9ce64bfcd2196.

Diff:
---
 gcc/fortran/trans-descriptor.cc | 30 +++++-------------------------
 gcc/fortran/trans-descriptor.h  |  3 +--
 2 files changed, 6 insertions(+), 27 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index bf799fb3e467..eb3009e5cea6 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -671,9 +671,9 @@ gfc_get_descriptor_offsets_for_info (const_tree desc_type, 
tree *data_off,
 #undef LBOUND_SUBFIELD
 #undef UBOUND_SUBFIELD
 
+
 void
-gfc_clear_descriptor (stmtblock_t *block, gfc_symbol *sym, gfc_expr *expr,
-                     tree descr, tree string_length)
+gfc_clear_descriptor (stmtblock_t *block, gfc_symbol *sym, tree descr)
 {
   symbol_attribute attr = gfc_symbol_attr (sym);
 
@@ -695,32 +695,12 @@ gfc_clear_descriptor (stmtblock_t *block, gfc_symbol 
*sym, gfc_expr *expr,
   else
     as = sym->as;
 
-  int rank;
-  if (as == nullptr)
-    rank = 0;
-  else if (as->type == AS_ASSUMED_RANK)
-    rank = expr->rank;
-  else
-    rank = as->rank;
-
-  gcc_assert (rank >= 0);
+  gcc_assert (as && as->rank >= 0);
   etype = gfc_get_element_type (TREE_TYPE (descr));
-  tree dtype = gfc_get_dtype_rank_type_slen (rank, etype, string_length);
-  gfc_conv_descriptor_dtype_set (block, descr, dtype);
-}
-
-void
-gfc_clear_descriptor (stmtblock_t *block, gfc_symbol *sym, gfc_expr *expr,
-                     tree descr)
-{
-  return gfc_clear_descriptor (block, sym, expr, descr, NULL_TREE);
+  gfc_conv_descriptor_dtype_set (block, descr,
+                                gfc_get_dtype_rank_type (as->rank, etype));
 }
 
-void
-gfc_clear_descriptor (stmtblock_t *block, gfc_symbol *sym, tree descr)
-{
-  return gfc_clear_descriptor (block, sym, nullptr, descr);
-}
 
 void
 gfc_clear_descriptor (tree descr)
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 884cd0d11a02..5c6587a13c07 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GFC_TRANS_DESCRIPTOR_H
 #define GFC_TRANS_DESCRIPTOR_H
 
+/* Build a null array descriptor constructor.  */
 void gfc_clear_descriptor (stmtblock_t *block, gfc_symbol *, gfc_expr *, tree);
 void gfc_set_scalar_null_descriptor (stmtblock_t *block, tree, gfc_symbol *, 
gfc_expr *, tree);
 void gfc_set_descriptor_with_shape (stmtblock_t *, tree, tree,
@@ -92,8 +93,6 @@ gfc_get_descriptor_offsets_for_info (const_tree desc_type, 
tree *data_off,
                                     tree *upper_suboff);
 
 tree gfc_build_default_class_descriptor (const gfc_typespec &, tree);
-void gfc_clear_descriptor (stmtblock_t *block, gfc_symbol *, gfc_expr *, tree, 
tree);
-void gfc_clear_descriptor (stmtblock_t *block, gfc_symbol *, gfc_expr *, tree);
 void gfc_clear_descriptor (stmtblock_t *block, gfc_symbol *sym, tree descr);
 void gfc_clear_descriptor (tree descr);
 void gfc_set_scalar_descriptor (stmtblock_t *, tree, tree);

Reply via email to