Patch, Fortran] FINAL (prep patches 5/5): Activate the generation of the finalization wrapper

Message ID
State New
Headers show

Commit Message

Tobias Burnus Dec. 31, 2012, 12:40 p.m.
(Patch 4/5, which adds support for noncontiguous arrays to the 
finalization wrapper follows soon; it works, but I should do a small 
cleanup before submittal.)

Contrary to the other patches in this series, this patch changes the 
generated code - and it changes the ABI. With this patch, the virtual 
table (vtab) gets a "_final" components between _copy and the user's 
type-bound procedures. Additionally, the finalization wrapper is generated.

Note: This patch only adds the finalization wrapper function - it does 
not use it. Thus, there is no user-visible benefit of this patch - 
except for the avoided 4.9 ABI issue.

The risk of this patch is rather low (only ICEs are possible).

The (only? main?) advantage of this patch is that it avoids ABI breakage 
for polymorphic variables immediately after branching 4.8. (Due to two 
recent patches, we have already broken the ABI for 4.8 and bumped the 
.mod version. Thus, this breakage could make use of the already bumped 
.mod file version number.)

Build and regtested on x86-64-gnu-linux.
OK for the 4.8 trunk? – Alternatively: OK for the 4.9 trunk?

* * *

The next step is make use of the finalization wrapper for both calling 
the user's finalization subroutines but also for deallocating 
allocatable components of polymorphic variables/components. 
("polymorphic freeing").

At I have a draft 
patch which handles some of the cases; however, the support is 
incomplete and there are possibly some issues.

One could consider supporting some subset of polymorphic freeing or 
finalization using the user's FINAL subroutines even for 4.8. However, 
it looks more like GCC 4.9 material. Comments?



2012-12-31  Tobias Burnus  <>

	* class.c (gfc_find_derived_vtab): Activate the generation
	of the finalization wrapper.

diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c
index 61d65e7..84f383e 100644
--- a/gcc/fortran/class.c
+++ b/gcc/fortran/class.c
@@ -2024,9 +2425,7 @@  gfc_find_derived_vtab (gfc_symbol *derived)
 		 components and the calls to finalization subroutines.
 		 Note: The actual wrapper function can only be generated
 		 at resolution time.  */
-	    /* FIXME: Enable ABI-breaking "_final" generation.  */
-	    if (0)
-	    {
 	      if (gfc_add_component (vtype, "_final", &c) == FAILURE)
 		goto cleanup;
 	      c->attr.proc_pointer = 1;
@@ -2034,7 +2433,6 @@  gfc_find_derived_vtab (gfc_symbol *derived)
 	      c->tb = XCNEW (gfc_typebound_proc);
 	      c->tb->ppc = 1;
 	      generate_finalization_wrapper (derived, ns, tname, c);
-	    }
 	      /* Add procedure pointers for type-bound procedures.  */
 	      if (!derived->attr.unlimited_polymorphic)