]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/60922 (Memory leak with allocatable CLASS components)
authorJanus Weil <janus@gcc.gnu.org>
Sat, 24 Jan 2015 10:11:52 +0000 (11:11 +0100)
committerJanus Weil <janus@gcc.gnu.org>
Sat, 24 Jan 2015 10:11:52 +0000 (11:11 +0100)
2015-01-24  Janus Weil  <janus@gcc.gnu.org>

Backport from mainline
PR fortran/60922
* class.c (finalize_component): Apply the check for 'fini_coarray' only
to coarray components.

2015-01-24  Janus Weil  <janus@gcc.gnu.org>

Backport from mainline
PR fortran/60922
* gfortran.dg/class_allocate_17.f90: New.

From-SVN: r220078

gcc/fortran/ChangeLog
gcc/fortran/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/class_allocate_17.f90 [new file with mode: 0644]

index 3828f1ab1f70bd8e73306f73fea013cf3db5ed28..cb7b7a6bae803f208e879d91b1267f1da0aa21bd 100644 (file)
@@ -1,3 +1,10 @@
+2015-01-24  Janus Weil  <janus@gcc.gnu.org>
+
+       Backport from mainline
+       PR fortran/60922
+       * class.c (finalize_component): Apply the check for 'fini_coarray' only
+       to coarray components.
+
 2015-01-14  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
index 346aee652052c229e0ff5ce90f059f60a4d453ee..f28c8ad407c1cf5db6414d7045818047e33d17c9 100644 (file)
@@ -875,7 +875,7 @@ finalize_component (gfc_expr *expr, gfc_symbol *derived, gfc_component *comp,
       /* Add IF (fini_coarray).  */
       if (comp->attr.codimension
          || (comp->ts.type == BT_CLASS && CLASS_DATA (comp)
-             && CLASS_DATA (comp)->attr.allocatable))
+             && CLASS_DATA (comp)->attr.codimension))
        {
          block = gfc_get_code (EXEC_IF);
          if (*code)
index fd9562a197eebe02dc78a8d89430a4ca03537dff..c2f61d911e616d221e860e43eabfa7cbdcfc7339 100644 (file)
@@ -1,3 +1,9 @@
+2015-01-24  Janus Weil  <janus@gcc.gnu.org>
+
+       Backport from mainline
+       PR fortran/60922
+       * gfortran.dg/class_allocate_17.f90: New.
+
 2015-01-20  Marek Polacek  <polacek@redhat.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/gfortran.dg/class_allocate_17.f90 b/gcc/testsuite/gfortran.dg/class_allocate_17.f90
new file mode 100644 (file)
index 0000000..639ba80
--- /dev/null
@@ -0,0 +1,32 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! PR 60922: [4.9/5 regression] Memory leak with allocatable CLASS components
+!
+! Contributed by Salvatore Filippone <sfilippone@uniroma2.it>
+
+program test_leak
+  implicit none
+
+  type d_base_vect_type
+  end type
+
+  type d_vect_type
+    class(d_base_vect_type), allocatable :: v
+  end type
+
+  call test()
+
+contains
+
+  subroutine test()
+    class(d_vect_type), allocatable :: x
+    allocate(x)
+    allocate(x%v)
+    print *,"allocated!"
+  end subroutine
+
+end
+
+! { dg-final { scan-tree-dump-times "fini_coarray" 1 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }