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

commit af2288fa0088790c29ad9fd5d784380972b3c753
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Thu Apr 24 20:53:34 2025 +0200

    Correction régression pr59586

Diff:
---
 gcc/fortran/trans-decl.cc | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 89db2e286969..326c687bf4fd 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -1257,6 +1257,26 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
       GFC_TYPE_ARRAY_SIZE (type) = create_index_var ("size", nest);
       suppress_warning (GFC_TYPE_ARRAY_SIZE (type));
     }
+
+  if (POINTER_TYPE_P (type))
+    {
+      gcc_assert (GFC_ARRAY_TYPE_P (TREE_TYPE (type)));
+      gcc_assert (TYPE_LANG_SPECIFIC (type)
+                 == TYPE_LANG_SPECIFIC (TREE_TYPE (type)));
+      type = TREE_TYPE (type);
+    }
+
+  if (! COMPLETE_TYPE_P (type) && GFC_TYPE_ARRAY_SIZE (type))
+    {
+      tree size, range;
+
+      size = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
+                             GFC_TYPE_ARRAY_SIZE (type), gfc_index_one_node);
+      range = build_range_type (gfc_array_index_type, gfc_index_zero_node,
+                               size);
+      TYPE_DOMAIN (type) = range;
+      layout_type (type);
+    }
 }

Reply via email to