]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fortran: Add missing cleanup blocks
authorMikael Morin <mikael@gcc.gnu.org>
Mon, 17 Jul 2023 12:13:37 +0000 (14:13 +0200)
committerMikael Morin <mikael@gcc.gnu.org>
Mon, 17 Jul 2023 12:13:37 +0000 (14:13 +0200)
Move cleanup code for the data descriptor after the finalization code
as it makes more sense to have it after.
Other cleanup blocks should be empty (element size and final pointer
are just data references), but add them by the way, just in case.

gcc/fortran/ChangeLog:

* trans.cc (gfc_add_finalizer_call): Add post code for desc_se
after the finalizer call.  Add post code for final_se and
size_se as well.

gcc/fortran/trans.cc

index 2af433d0952957b1fa878b0227348779ef737a14..7fcaf8ea9cf274b1dbcbc62c87ebecb1db0ba6c3 100644 (file)
@@ -1390,8 +1390,12 @@ gfc_add_finalizer_call (stmtblock_t *block, gfc_expr *expr2)
                             desc_se.expr, size_se.expr,
                             boolean_false_node);
 
-  gfc_add_block_to_block (&tmp_block, &desc_se.post);
   gfc_add_expr_to_block (&tmp_block, tmp);
+
+  gfc_add_block_to_block (&tmp_block, &desc_se.post);
+  gfc_add_block_to_block (&tmp_block, &size_se.post);
+  gfc_add_block_to_block (&tmp_block, &final_se.post);
+
   tmp = gfc_finish_block (&tmp_block);
 
   if (expr->ts.type == BT_CLASS && !has_finalizer)