Patchwork [Fortran] PR58356 - fix ICE with finalizer in type extension

login
register
mail settings
Submitter Tobias Burnus
Date Sept. 15, 2013, 12:51 p.m.
Message ID <5235AD49.30303@net-b.de>
Download mbox | patch
Permalink /patch/275019/
State New
Headers show

Comments

Tobias Burnus - Sept. 15, 2013, 12:51 p.m.
A rather obvious patch.

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

Tobias
Janus Weil - Sept. 16, 2013, 12:47 p.m.
> A rather obvious patch.
>
> Build and regtested on x86-64-gnu-linux.
> OK for the trunk?

Looks good to me!

Thanks,
Janus

Patch

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

	PR fortran/58356
	* class.c (generate_finalization_wrapper): Init proc_tree if
	not yet resolved.

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

	PR fortran/58356
	* gfortran.dg/finalize_19.f90: New.

diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c
index 629b052..7117e83 100644
--- a/gcc/fortran/class.c
+++ b/gcc/fortran/class.c
@@ -1881,6 +1881,8 @@  generate_finalization_wrapper (gfc_symbol *derived, gfc_namespace *ns,
 
       for (fini = derived->f2k_derived->finalizers; fini; fini = fini->next)
 	{
+	  if (!fini->proc_tree)
+	    fini->proc_tree = gfc_find_sym_in_symtree (fini->proc_sym);
 	  if (fini->proc_tree->n.sym->attr.elemental)
 	    {
 	      fini_elem = fini;
diff --git a/gcc/testsuite/gfortran.dg/finalize_19.f90 b/gcc/testsuite/gfortran.dg/finalize_19.f90
new file mode 100644
index 0000000..1eeb6af
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/finalize_19.f90
@@ -0,0 +1,21 @@ 
+! { dg-do compile }
+!
+! PR fortran/58356
+!
+! Contributed by Andrew Benson
+!
+module ct
+  type :: cfl
+   contains
+     final :: cfld
+  end type cfl
+  type, extends(cfl) :: cfde
+   contains
+  end type cfde
+contains
+  subroutine cfld(self)
+    implicit none
+    type(cfl), intent(inout) :: self
+    return
+  end subroutine cfld
+end module ct