]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: fix FE memleak
authorHarald Anlauf <anlauf@gmx.de>
Wed, 3 Jan 2024 19:21:00 +0000 (20:21 +0100)
committerHarald Anlauf <anlauf@gmx.de>
Sat, 23 Mar 2024 19:42:27 +0000 (20:42 +0100)
gcc/fortran/ChangeLog:

* trans-types.cc (gfc_get_nodesc_array_type): Clear used gmp
variables.

gcc/fortran/trans-types.cc

index b514d8e5a57bf50caab5f7313301cc8f2f631143..b2a3000da1fe39cd954c6b3192d301a171323f80 100644 (file)
@@ -1791,7 +1791,7 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed,
          TYPE_LANG_SPECIFIC (type) = TYPE_LANG_SPECIFIC (TREE_TYPE (type));
        }
 
-      return type;
+      goto array_type_done;
     }
 
   if (known_stride)
@@ -1810,10 +1810,6 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed,
 
   layout_type (type);
 
-  mpz_clear (offset);
-  mpz_clear (stride);
-  mpz_clear (delta);
-
   /* Represent packed arrays as multi-dimensional if they have rank >
      1 and with proper bounds, instead of flat arrays.  This makes for
      better debug info.  */
@@ -1844,6 +1840,12 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * as, gfc_packed packed,
       GFC_ARRAY_TYPE_P (type) = 1;
       TYPE_LANG_SPECIFIC (type) = TYPE_LANG_SPECIFIC (TREE_TYPE (type));
     }
+
+array_type_done:
+  mpz_clear (offset);
+  mpz_clear (stride);
+  mpz_clear (delta);
+
   return type;
 }