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

commit dd580e260358b2229832c708a11d347715296c55
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 8f5e78bf1ffd..89db2e286969 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -1212,13 +1212,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