[gcc(refs/users/mikael/heads/refactor_descriptor_v291.01)] Modif gfc_init_descriptor_variable

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

commit 1a53151d46fe2d0b3dd6f757a5e95d4487e4f295
Author: Mikael Morin <[email protected]>
Date:   Sat Jul 19 15:55:19 2025 +0200

    Modif gfc_init_descriptor_variable

Diff:
---
 gcc/fortran/trans-descriptor.cc | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index cd1658b73ff3..23c74dded4f6 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -910,19 +910,26 @@ gfc_init_static_descriptor (tree descr)
 void
 gfc_init_descriptor_variable (stmtblock_t *block, gfc_symbol *sym, tree descr)
 {
+  symbol_attribute attr = gfc_symbol_attr (sym);
+
   /* NULLIFY the data pointer for non-saved allocatables, or for non-saved
      pointers when -fcheck=pointer is specified.  */
-  if (sym->attr.allocatable
-      || (sym->attr.pointer && (gfc_option.rtcheck & GFC_RTCHECK_POINTER)))
+  if (attr.allocatable
+      || (attr.pointer && (gfc_option.rtcheck & GFC_RTCHECK_POINTER)))
     {
       gfc_conv_descriptor_data_set (block, descr, null_pointer_node);
-      if (flag_coarray == GFC_FCOARRAY_LIB && sym->attr.codimension)
+      if (flag_coarray == GFC_FCOARRAY_LIB && attr.codimension)
 	gfc_conv_descriptor_token_set (block, descr, null_pointer_node);
     }
 
-  gcc_assert (sym->as && sym->as->rank>=0);
+  gfc_array_spec *as;
+  if (sym->ts.type == BT_CLASS)
+    as = CLASS_DATA (sym)->as;
+  else
+    as = sym->as;
+
+  gcc_assert (as && as->rank >= 0);
   tree etype = gfc_get_element_type (TREE_TYPE (descr));
   gfc_conv_descriptor_dtype_set (block, descr,
-				 gfc_get_dtype_rank_type (sym->as->rank,
-							  etype));
+				 gfc_get_dtype_rank_type (as->rank, 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.