re PR fortran/60922 (Memory leak with allocatable CLASS components)
authorJanus Weil <janus@gcc.gnu.org>
Fri, 23 Jan 2015 08:32:09 +0000 (09:32 +0100)
committerJanus Weil <janus@gcc.gnu.org>
Fri, 23 Jan 2015 08:32:09 +0000 (09:32 +0100)
2015-01-23  Janus Weil  <janus@gcc.gnu.org>

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

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

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

From-SVN: r220029

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

index 51d7b59e89051b032b1ff37e35ec10258f47faaa..0695b22ff16dd3bcd134157000e09b617451049a 100644 (file)
@@ -1,3 +1,9 @@
+2015-01-23  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/60922
+       * class.c (finalize_component): Apply the check for 'fini_coarray' only
+       to coarray components.
+
 2015-01-23  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/64726
index a9b65e65b2b1abbc50a940333b83a9389467debd..55e7ef4a56bab3a9c6d69c3be67763db69f36277 100644 (file)
@@ -928,7 +928,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 20528c36138c670675ad1b3721e8b368c3857fab..efcbc8691506ec89151a67156a68c44f93deed1f 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-23  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/60922
+       * gfortran.dg/class_allocate_17.f90: New.
+
 2015-01-23  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/64726
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" } }