[Fortran] Enable the generation of the FINALization wrapper function

Message ID 51A60118.9020707@net-b.de
State New
Headers show

Commit Message

Tobias Burnus May 29, 2013, 1:22 p.m.
Janus Weil wrote:
>> Build and regtested on x86-64-gnu-linux.
>> OK for the trunk?
> I think this patch is ok. Just one nit:
> @@ -5571,7 +5569,7 @@ gfc_dump_module (const char *name, int dump_flag)
>        FIXME: For backwards compatibility with the old uncompressed
>        module format, write an extra empty line. When the module version
>        is bumped, this can be removed.  */
> -  gzprintf (module_fp, "GFORTRAN module version '%s' created from %s\n\n",
> +  gzprintf (module_fp, "GFORTRAN module version '%s' created from %s\n",
>           MOD_VERSION, gfc_source_file);
> Here you should remove the FIXME.

I thought I had done this - but seemingly I missed that one. DONE.

Dominique was that brave and tested the posted patches. Doing so, he 
found that the finalization wrapper causes an ICE with -m32. The reason 
is that I use gfc_convert_type to convert the kind value of result 
variable of the RANK intrinsic.

It turned out that calling that for a no op conversion leads to an ICE 
(internal error). (The conversion is supposed to convert the 
default-kind result value to the gfc_array_index_kind, otherwise one 
runs into an ICE at tree level.) Well, the solution is simple: Only 
convert it when needed. Hence, I included the following patch in the 
committal (Rev. 199409).

+    gfc_convert_type_warn (rank, &idx->ts, 2, 0);

Thanks to both of you for the review and the testing.

  * * *

Now the important ingredients for finalization are all in, the next task 
is to actually do finalization. The first patch has been posted, but it 
will take a while until all finalization calls will be available.



--- a/gcc/fortran/class.c
+++ b/gcc/fortran/class.c
@@ -1644 +1644,2 @@  generate_finalization_wrapper (gfc_symbol *derived, 
gfc_namespace *ns,
-  gfc_convert_type (rank, &idx->ts, 2);
+  if (rank->ts.kind != idx->ts.kind)