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

commit e2cf3a9b8827810f5db6ec53acc193a50dff8923
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Fri Apr 25 15:51:31 2025 +0200

    Correction régression repack_arrays_1

Diff:
---
 gcc/fortran/trans-array.cc | 6 ++++++
 gcc/fortran/trans-decl.cc  | 4 +++-
 gcc/fortran/trans-types.cc | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index b6688af5953d..e32f92387d60 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -6276,6 +6276,12 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * 
sym,
   if (!onstack)
     type = TREE_TYPE (type);
 
+  if (!GFC_TYPE_ARRAY_ELEM_LEN (type))
+    {
+      gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE);
+      return;
+    }
+
   size = gfc_trans_array_bounds (type, sym, &offset, &init);
 
   /* Set offset of the array.  */
diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 067a33c2994f..80c00d132b2a 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -1258,7 +1258,9 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
       suppress_warning (GFC_TYPE_ARRAY_SIZE (type));
     }
 
-  if (! COMPLETE_TYPE_P (type) && GFC_TYPE_ARRAY_SIZE (type))
+  if (! COMPLETE_TYPE_P (type)
+      && GFC_TYPE_ARRAY_SIZE (type)
+      && GFC_DECL_PACKED_ARRAY (decl))
     {
       tree size, range;
 
diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index 92d592f52f12..d67a64b363ab 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -1866,7 +1866,7 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * 
as, gfc_packed packed,
   mpz_init_set_ui (stride, 1);
   mpz_init (spc);
 
-  bool known_spacing = INTEGER_CST_P (TYPE_SIZE_UNIT (etype));
+  bool known_spacing = packed != PACKED_NO && INTEGER_CST_P (TYPE_SIZE_UNIT 
(etype));
   if (known_spacing)
     {
       wide_int elem_len = wi::to_wide (TYPE_SIZE_UNIT (etype));

Reply via email to