re PR fortran/57542 ([OOP] ICE on FINALization with specific options)
authorTobias Burnus <burnus@net-b.de>
Thu, 6 Jun 2013 14:36:41 +0000 (16:36 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Thu, 6 Jun 2013 14:36:41 +0000 (16:36 +0200)
2013-06-06  Tobias Burnus  <burnus@net-b.de>

        PR fortran/57542
        * trans.c (gfc_build_final_call): Add se.pre to the block
        and modify the assert.

2013-06-06  Tobias Burnus  <burnus@net-b.de>

        PR fortran/57542
        * gfortran.dg/finalize_16.f90: New.

From-SVN: r199736

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

index d8ff752e588389a4a4ba2f1fc315be1e3adc9b83..442bdfee4896fcac4671fc05fc5c3f403d9c9e5f 100644 (file)
@@ -1,3 +1,9 @@
+2013-06-06  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/57542
+       * trans.c (gfc_build_final_call): Add se.pre to the block
+       and modify the assert.
+
 2013-06-04  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/37336
index a1ea3008ff7390a03eca93af97761a1549c14300..dd608b7f22bf8c29f9b108497e19819f6a07d6b7 100644 (file)
@@ -895,7 +895,8 @@ gfc_build_final_call (gfc_typespec ts, gfc_expr *final_wrapper, gfc_expr *var,
       gcc_assert (class_size);
       gfc_init_se (&se, NULL);
       gfc_conv_expr (&se, class_size);
-      gcc_assert (se.pre.head == NULL_TREE && se.post.head == NULL_TREE);
+      gfc_add_block_to_block (&block, &se.pre);
+      gcc_assert (se.post.head == NULL_TREE);
       size = se.expr;
 
       array_expr = gfc_copy_expr (var);
@@ -912,7 +913,8 @@ gfc_build_final_call (gfc_typespec ts, gfc_expr *final_wrapper, gfc_expr *var,
        {
          gfc_add_data_component (array_expr);
          gfc_conv_expr (&se, array_expr);
-         gcc_assert (se.pre.head == NULL_TREE && se.post.head == NULL_TREE);
+         gfc_add_block_to_block (&block, &se.pre);
+         gcc_assert (se.post.head == NULL_TREE);
          array = se.expr;
          if (TREE_CODE (array) == ADDR_EXPR
              && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (array, 0))))
index 6385c7dc3b870ee375347a3891687502437865fd..67b5d6331f2d9023b6073d303f1d973625978d6f 100644 (file)
@@ -1,3 +1,8 @@
+2013-06-06  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/57542
+       * gfortran.dg/finalize_16.f90: New.
+
 2013-06-06  Marcus Shawcroft  <marcus.shawcroft@arm.com>
 
        * gcc.dg/vect/no-section-anchors-vect-68.c:
diff --git a/gcc/testsuite/gfortran.dg/finalize_16.f90 b/gcc/testsuite/gfortran.dg/finalize_16.f90
new file mode 100644 (file)
index 0000000..89c5cfb
--- /dev/null
@@ -0,0 +1,32 @@
+! { dg-do compile }
+! { dg-options "-fcheck=all" }
+!
+! PR fortran/57542
+!
+! Contributed by Salvatore Filippone
+!
+module type_mod
+  type inner
+  end type inner
+
+  type outer 
+    class(inner), allocatable :: item
+  end type outer
+
+  type container 
+    class(outer), allocatable :: item
+  end type container
+
+  type maintype
+    type(container), allocatable :: v(:)
+  end type maintype
+
+end module type_mod
+
+subroutine testfinal(var)
+  use type_mod
+  type(maintype), intent(inout) :: var
+  ! A real code would obviously check
+  ! this is really allocated
+  deallocate(var%v(1)%item%item)
+end subroutine testfinal