https://gcc.gnu.org/g:26fb966af321a60f37293d4e49e2c6afba3b781b

commit 26fb966af321a60f37293d4e49e2c6afba3b781b
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Thu Apr 17 17:38:15 2025 +0200

    Correction régression pr95827

Diff:
---
 gcc/fortran/trans-decl.cc | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 3aa84f8b94f0..7628f9da6a49 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -1214,13 +1214,16 @@ gfc_build_qualified_array (tree decl, gfc_symbol * sym)
       type = TREE_TYPE (type);
     }
 
-  tree new_type = update_type_bounds (type, lbound, ubound, spacing, type,
-                                     as->rank - 1);
-  if (POINTER_TYPE_P (TREE_TYPE (decl)))
-    TREE_TYPE (TREE_TYPE (decl)) = new_type;
-  else
-    TREE_TYPE (decl) = new_type;
-  type = new_type;
+  if (as->rank > 0)
+    {
+      tree new_type = update_type_bounds (type, lbound, ubound, spacing, type,
+                                         as->rank - 1);
+      if (POINTER_TYPE_P (TREE_TYPE (decl)))
+       TREE_TYPE (TREE_TYPE (decl)) = new_type;
+      else
+       TREE_TYPE (decl) = new_type;
+      type = new_type;
+    }
 
   for (dim = GFC_TYPE_ARRAY_RANK (type);
        dim < GFC_TYPE_ARRAY_RANK (type) + GFC_TYPE_ARRAY_CORANK (type); dim++)

Reply via email to