Commit 5285d5d3 by Janus Weil

re PR fortran/79311 ([OOP] ICE in generate_finalization_wrapper, at fortran/class.c:1992)

2017-05-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/79311
	* resolve.c (gfc_resolve_finalizers): Ensure that derived-type
	components have a their finalizers resolved, also if the superordinate
	type itself has a finalizer.

2017-05-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/79311
	* gfortran.dg/finalize_32.f90: New test.

From-SVN: r247818
parent c0aad677
2017-05-09 Janus Weil <janus@gcc.gnu.org>
PR fortran/79311
* resolve.c (gfc_resolve_finalizers): Ensure that derived-type
components have a their finalizers resolved, also if the superordinate
type itself has a finalizer.
2017-05-08 Thomas Koenig <tkoenig@gcc.gnu.org> 2017-05-08 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/79930 PR fortran/79930
......
...@@ -12385,27 +12385,24 @@ gfc_resolve_finalizers (gfc_symbol* derived, bool *finalizable) ...@@ -12385,27 +12385,24 @@ gfc_resolve_finalizers (gfc_symbol* derived, bool *finalizable)
if (parent) if (parent)
gfc_resolve_finalizers (parent, finalizable); gfc_resolve_finalizers (parent, finalizable);
/* Return early when not finalizable. Additionally, ensure that derived-type /* Ensure that derived-type components have a their finalizers resolved. */
components have a their finalizables resolved. */ bool has_final = derived->f2k_derived && derived->f2k_derived->finalizers;
if (!derived->f2k_derived || !derived->f2k_derived->finalizers)
{
bool has_final = false;
for (c = derived->components; c; c = c->next) for (c = derived->components; c; c = c->next)
if (c->ts.type == BT_DERIVED if (c->ts.type == BT_DERIVED
&& !c->attr.pointer && !c->attr.proc_pointer && !c->attr.allocatable) && !c->attr.pointer && !c->attr.proc_pointer && !c->attr.allocatable)
{ {
bool has_final2 = false; bool has_final2 = false;
if (!gfc_resolve_finalizers (c->ts.u.derived, &has_final)) if (!gfc_resolve_finalizers (c->ts.u.derived, &has_final2))
return false; /* Error. */ return false; /* Error. */
has_final = has_final || has_final2; has_final = has_final || has_final2;
} }
/* Return early if not finalizable. */
if (!has_final) if (!has_final)
{ {
if (finalizable) if (finalizable)
*finalizable = false; *finalizable = false;
return true; return true;
} }
}
/* Walk over the list of finalizer-procedures, check them, and if any one /* Walk over the list of finalizer-procedures, check them, and if any one
does not fit in with the standard's definition, print an error and remove does not fit in with the standard's definition, print an error and remove
......
2017-05-09 Janus Weil <janus@gcc.gnu.org>
PR fortran/79311
* gfortran.dg/finalize_32.f90: New test.
2017-05-09 Volker Reichelt <v.reichelt@netcologne.de> 2017-05-09 Volker Reichelt <v.reichelt@netcologne.de>
PR c/35441 PR c/35441
......
! { dg-do compile }
!
! PR 79311: [OOP] ICE in generate_finalization_wrapper, at fortran/class.c:1992
!
! Contributed by DIL <liakhdi@ornl.gov>
module tensor_recursive
implicit none
type :: tens_signature_t
contains
final :: tens_signature_dtor
end type
type :: tens_header_t
type(tens_signature_t) :: signature
contains
final :: tens_header_dtor
end type
contains
subroutine tens_signature_dtor(this)
type(tens_signature_t) :: this
end subroutine
subroutine tens_header_dtor(this)
type(tens_header_t) :: this
end subroutine
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment