Commit cdeb16cb by Janus Weil

re PR fortran/61767 ([OOP] ICE in generate_finalization_wrapper at fortran/class.c:1491)

2016-12-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/61767
	* class.c (has_finalizer_component): Fix this function to detect only
	non-pointer non-allocatable components which have a finalizer.

2016-12-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/61767
	* gfortran.dg/finalize_31.f90: New test.

From-SVN: r243483
parent ffaf9305
2016-12-09 Janus Weil <janus@gcc.gnu.org>
PR fortran/61767
* class.c (has_finalizer_component): Fix this function to detect only
non-pointer non-allocatable components which have a finalizer.
2016-12-09 Andre Vehreschild <vehre@gcc.gnu.org> 2016-12-09 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/78505 PR fortran/78505
......
...@@ -841,17 +841,16 @@ has_finalizer_component (gfc_symbol *derived) ...@@ -841,17 +841,16 @@ has_finalizer_component (gfc_symbol *derived)
gfc_component *c; gfc_component *c;
for (c = derived->components; c; c = c->next) for (c = derived->components; c; c = c->next)
if (c->ts.type == BT_DERIVED && !c->attr.pointer && !c->attr.allocatable)
{ {
if (c->ts.type == BT_DERIVED && c->ts.u.derived->f2k_derived if (c->ts.u.derived->f2k_derived
&& c->ts.u.derived->f2k_derived->finalizers) && c->ts.u.derived->f2k_derived->finalizers)
return true; return true;
/* Stop infinite recursion through this function by inhibiting /* Stop infinite recursion through this function by inhibiting
calls when the derived type and that of the component are calls when the derived type and that of the component are
the same. */ the same. */
if (c->ts.type == BT_DERIVED if (!gfc_compare_derived_types (derived, c->ts.u.derived)
&& !gfc_compare_derived_types (derived, c->ts.u.derived)
&& !c->attr.pointer && !c->attr.allocatable
&& has_finalizer_component (c->ts.u.derived)) && has_finalizer_component (c->ts.u.derived))
return true; return true;
} }
......
2016-12-09 Janus Weil <janus@gcc.gnu.org>
PR fortran/61767
* gfortran.dg/finalize_31.f90: New test.
2016-12-09 Andre Vehreschild <vehre@gcc.gnu.org> 2016-12-09 Andre Vehreschild <vehre@gcc.gnu.org>
PR fortran/78505 PR fortran/78505
......
! { dg-do run }
!
! PR 61767: [OOP] ICE in generate_finalization_wrapper at fortran/class.c:1491
!
! Contributed by <reubendb@gmail.com>
module Communicator_Form
implicit none
type :: CommunicatorForm
contains
final :: Finalize
end type
type :: MessageTemplate
type ( CommunicatorForm ), pointer :: Communicator
end type
contains
subroutine Finalize ( C )
type ( CommunicatorForm ) :: C
! should not be called
call abort()
end subroutine
end module
program p
use Communicator_Form
implicit none
class ( MessageTemplate ), pointer :: M
allocate(M)
deallocate(M)
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