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

commit fc07ec039ccc7f13ac4cdd4373c45371646dc933
Author: Mikael Morin <[email protected]>
Date:   Fri Oct 3 19:49:57 2025 +0200

    Correction régression dependency_19.f90

Diff:
---
 gcc/fortran/trans-descriptor.cc | 54 +++++++++++++++++++++++++++++++++++------
 gcc/fortran/trans-types.cc      | 54 ++++++++++++++++++++++++++++++-----------
 gcc/fortran/trans-types.h       |  1 +
 gcc/tree-ssa-loop-ivopts.cc     |  4 ++-
 4 files changed, 90 insertions(+), 23 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 9fe8d8a22b13..2172f2e72b12 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -186,10 +186,14 @@ enum dtype_subfield
   GFC_DTYPE_VERSION,
   GFC_DTYPE_RANK,
   GFC_DTYPE_TYPE,
-  GFC_DTYPE_ATTRIBUTE,
-  GFC_DTYPE_BYTES_COUNTED_STRIDES
+  GFC_DTYPE_ATTR
 };
 
+enum attr_subfield
+{
+  GFC_ATTR_ATTRIBUTE,
+  GFC_ATTR_BYTES_COUNTED_STRIDES
+};
 
 static tree
 get_type_field (tree type, unsigned field_idx, tree field_type = NULL_TREE)
@@ -470,10 +474,25 @@ gfc_conv_descriptor_type_set (tree desc, int value)
 }
 
 
+static tree
+get_attr_comp (tree desc)
+{
+  return get_dtype_comp (desc, GFC_DTYPE_ATTR, gfc_get_attr_type_node ());
+}
+
+
+static tree
+get_attr_comp (tree desc, attr_subfield field, tree type = NULL_TREE)
+{
+  tree attr_ref = get_attr_comp (desc);
+  return get_ref_comp (attr_ref, field, type);
+}
+
+
 static tree
 get_descriptor_bytes_counted_strides (tree desc)
 {
-  return get_dtype_comp (desc, GFC_DTYPE_BYTES_COUNTED_STRIDES, 
short_unsigned_type_node);
+  return get_attr_comp (desc, GFC_ATTR_BYTES_COUNTED_STRIDES, 
short_unsigned_type_node);
 }
 
 static void
@@ -490,8 +509,8 @@ gfc_conv_descriptor_bytes_counted_strides_set (stmtblock_t 
*block, tree desc, in
   gcc_assert (value == 0 || value == 1);
 
   tree dtype = get_type_field (type, DTYPE_FIELD);
-
-  tree field = get_type_field (TREE_TYPE (dtype), 
GFC_DTYPE_BYTES_COUNTED_STRIDES);
+  tree attr = get_type_field (TREE_TYPE (dtype), GFC_DTYPE_ATTR);
+  tree field = get_type_field (TREE_TYPE (attr), 
GFC_ATTR_BYTES_COUNTED_STRIDES);
 
   tree type_value = build_int_cst (TREE_TYPE (field), value);
   gfc_conv_descriptor_bytes_counted_strides_set (block, desc, type_value);
@@ -729,6 +748,26 @@ gfc_conv_descriptor_extent_get (tree desc, tree dim)
  * Array descriptor higher level routines.                                     
*
  
******************************************************************************/
 
+static tree
+get_attr_constructor (bool bytes_counted_strides)
+{
+  tree attr;
+  tree field;
+  vec<constructor_elt, va_gc> *v = NULL;
+
+  tree attr_type_node = gfc_get_attr_type_node ();
+  field = gfc_advance_chain (TYPE_FIELDS (attr_type_node),
+                            GFC_ATTR_BYTES_COUNTED_STRIDES);
+  CONSTRUCTOR_APPEND_ELT (v, field,
+                         build_int_cst (TREE_TYPE (field),
+                                        bytes_counted_strides));
+
+  attr = build_constructor (attr_type_node, v);
+
+  return attr;
+}
+
+
 /* Return the DTYPE for an array.  This describes the type and type parameters
    of the array.  */
 /* TODO: Only call this when the value is actually used, and make all the
@@ -842,10 +881,9 @@ gfc_get_dtype_rank_type_slen (int rank, tree etype, bool 
bytes_counted_strides,
                          build_int_cst (TREE_TYPE (field), n));
 
   field = gfc_advance_chain (TYPE_FIELDS (dtype_type_node),
-                            GFC_DTYPE_BYTES_COUNTED_STRIDES);
+                            GFC_DTYPE_ATTR);
   CONSTRUCTOR_APPEND_ELT (v, field,
-                         build_int_cst (TREE_TYPE (field),
-                                        bytes_counted_strides));
+                         get_attr_constructor (bytes_counted_strides));
 
   dtype = build_constructor (dtype_type_node, v);
 
diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index eb58cbc4cdad..05e15658408b 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -138,8 +138,45 @@ int gfc_size_kind;
 int gfc_numeric_storage_size;
 int gfc_character_storage_size;
 
-static tree dtype_type_node = NULL_TREE;
 
+static tree attr_type_node = NULL_TREE;
+
+tree gfc_get_attr_type_node (void)
+{
+  tree field;
+  tree attr_node;
+  tree *attr_chain = NULL;
+
+  if (attr_type_node == NULL_TREE)
+    {
+      attr_node = make_node (RECORD_TYPE);
+      TYPE_NAME (attr_node) = get_identifier ("attr_type");
+      TYPE_NAMELESS (attr_node) = 1;
+      field = gfc_add_field_to_struct_1 (attr_node,
+                                        get_identifier ("attribute"),
+                                        short_unsigned_type_node, &attr_chain);
+      DECL_BIT_FIELD (field) = 1;
+      tree type_size = TYPE_SIZE (TREE_TYPE (field));
+      DECL_SIZE (field) = int_const_binop (MINUS_EXPR, type_size,
+                                          build_one_cst (TREE_TYPE 
(type_size)));
+      suppress_warning (field);
+
+      field = gfc_add_field_to_struct_1 (attr_node,
+                                        get_identifier 
("bytes_counted_strides"),
+                                        short_unsigned_type_node, &attr_chain);
+      DECL_BIT_FIELD (field) = 1;
+      DECL_SIZE (field) = bitsize_int (1);
+      suppress_warning (field);
+
+      gfc_finish_type (attr_node);
+      TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (attr_node)) = 1;
+      attr_type_node = attr_node;
+    }
+  return attr_type_node;
+}
+
+
+static tree dtype_type_node = NULL_TREE;
 
 /* Build the dtype_type_node if necessary.  */
 tree get_dtype_type_node (void)
@@ -170,19 +207,8 @@ tree get_dtype_type_node (void)
                                         signed_char_type_node, &dtype_chain);
       suppress_warning (field);
       field = gfc_add_field_to_struct_1 (dtype_node,
-                                        get_identifier ("attribute"),
-                                        short_unsigned_type_node, 
&dtype_chain);
-      DECL_BIT_FIELD (field) = 1;
-      tree type_size = TYPE_SIZE (TREE_TYPE (field));
-      DECL_SIZE (field) = int_const_binop (MINUS_EXPR, type_size,
-                                          build_one_cst (TREE_TYPE 
(type_size)));
-      suppress_warning (field);
-
-      field = gfc_add_field_to_struct_1 (dtype_node,
-                                        get_identifier 
("bytes_counted_strides"),
-                                        short_unsigned_type_node, 
&dtype_chain);
-      DECL_BIT_FIELD (field) = 1;
-      DECL_SIZE (field) = bitsize_int (1);
+                                        get_identifier ("attr"),
+                                        gfc_get_attr_type_node (), 
&dtype_chain);
       suppress_warning (field);
 
       gfc_finish_type (dtype_node);
diff --git a/gcc/fortran/trans-types.h b/gcc/fortran/trans-types.h
index 5189f4966286..c785be1549e2 100644
--- a/gcc/fortran/trans-types.h
+++ b/gcc/fortran/trans-types.h
@@ -75,6 +75,7 @@ void gfc_init_types (void);
 void gfc_init_c_interop_kinds (void);
 
 tree get_dtype_type_node (void);
+tree gfc_get_attr_type_node (void);
 tree gfc_get_int_type (int);
 tree gfc_get_unsigned_type (int);
 tree gfc_get_real_type (int);
diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc
index ba727adc808d..4b479db6f287 100644
--- a/gcc/tree-ssa-loop-ivopts.cc
+++ b/gcc/tree-ssa-loop-ivopts.cc
@@ -2239,7 +2239,9 @@ find_interesting_uses_address (struct ivopts_data *data, 
gimple *stmt,
 
   /* Ignore bitfields for now.  Not really something terribly complicated
      to handle.  TODO.  */
-  if (TREE_CODE (base) == BIT_FIELD_REF)
+  if (TREE_CODE (base) == BIT_FIELD_REF
+      || (TREE_CODE (base) == COMPONENT_REF
+         && DECL_BIT_FIELD (TREE_OPERAND (base, 1))))
     goto fail;
 
   base = unshare_expr (base);

Reply via email to