Patchwork [Fortran] FINAL (prep patches 1/5): Add _final to intrinsic vtables for CLASS(*)

login
register
mail settings
Submitter Tobias Burnus
Date Dec. 31, 2012, 12:16 p.m.
Message ID <50E18236.6070101@net-b.de>
Download mbox | patch
Permalink /patch/208849/
State New
Headers show

Comments

Tobias Burnus - Dec. 31, 2012, 12:16 p.m.
This simple patch fixes a wrong indent and adds a _final component to 
the virtual tables generated for intrinsic types.

This patch not only prepares the trunk for finalization support, it also 
avoids ABI issues which a later addition would cause. (For intrinsic 
types, changing the .mod version number will not reliable force a 
recompilation.)

Build on x86-64-gnu-linux.
OK for the trunk?

Tobias
Paul Richard Thomas - Jan. 4, 2013, 9:05 p.m.
Dear Tobias,

This one is 'obvious' - OK for trunk.

Thanks

Paul

On 31 December 2012 13:16, Tobias Burnus <burnus@net-b.de> wrote:
> This simple patch fixes a wrong indent and adds a _final component to the
> virtual tables generated for intrinsic types.
>
> This patch not only prepares the trunk for finalization support, it also
> avoids ABI issues which a later addition would cause. (For intrinsic types,
> changing the .mod version number will not reliable force a recompilation.)
>
> Build on x86-64-gnu-linux.
> OK for the trunk?
>
> Tobias

Patch

2012-12-31  Tobias Burnus  <burnus@net-b.de>

	* class.c (gfc_find_intrinsic_vtab): Add _final
	component.

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
@@ -597,7 +597,7 @@  gfc_build_class_symbol (gfc_typespec *ts, symbol_attribute *attr,
       fclass->refs++;
       fclass->ts.type = BT_UNKNOWN;
       if (!ts->u.derived->attr.unlimited_polymorphic)
-      fclass->attr.abstract = ts->u.derived->attr.abstract;
+	fclass->attr.abstract = ts->u.derived->attr.abstract;
       fclass->f2k_derived = gfc_get_namespace (NULL, 0);
       if (gfc_add_flavor (&fclass->attr, FL_DERIVED,
 	  NULL, &gfc_current_locus) == FAILURE)
@@ -2310,6 +2708,15 @@  gfc_find_intrinsic_vtab (gfc_typespec *ts)
 	      /* Set initializer.  */
 	      c->initializer = gfc_lval_expr_from_sym (copy);
 	      c->ts.interface = copy;
+
+	      /* Add component _final.  */
+	      if (gfc_add_component (vtype, "_final", &c) == FAILURE)
+		goto cleanup;
+	      c->attr.proc_pointer = 1;
+	      c->attr.access = ACCESS_PRIVATE;
+	      c->tb = XCNEW (gfc_typebound_proc);
+	      c->tb->ppc = 1;
+	      c->initializer = gfc_get_null_expr (NULL);
 	    }
 	  vtab->ts.u.derived = vtype;
 	  vtab->value = gfc_default_initializer (&vtab->ts);