Commit b6c77bcb by Janus Weil

re PR fortran/47463 ([OOP] ICE in gfc_add_component_ref)

2011-01-31  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/47463
	* resolve.c (resolve_typebound_subroutine): Bug fix for the case of
	an argument of a typebound assignment being a component.


2011-01-31  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/47463
	* gfortran.dg/typebound_assignment_1.f03: New.

From-SVN: r169443
parent 0425d6f5
2011-01-31 Janus Weil <janus@gcc.gnu.org>
PR fortran/47463
* resolve.c (resolve_typebound_subroutine): Bug fix for the case of
an argument of a typebound assignment being a component.
2011-01-31 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2011-01-31 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gfortranspec.c (add_arg_libgfortran) [HAVE_LD_STATIC_DYNAMIC] Use * gfortranspec.c (add_arg_libgfortran) [HAVE_LD_STATIC_DYNAMIC] Use
......
...@@ -5877,14 +5877,12 @@ resolve_typebound_subroutine (gfc_code *code) ...@@ -5877,14 +5877,12 @@ resolve_typebound_subroutine (gfc_code *code)
/* Deal with typebound operators for CLASS objects. */ /* Deal with typebound operators for CLASS objects. */
expr = code->expr1->value.compcall.base_object; expr = code->expr1->value.compcall.base_object;
if (expr && expr->symtree->n.sym->ts.type == BT_CLASS if (expr && expr->ts.type == BT_CLASS && code->expr1->value.compcall.name)
&& code->expr1->value.compcall.name)
{ {
/* Since the typebound operators are generic, we have to ensure /* Since the typebound operators are generic, we have to ensure
that any delays in resolution are corrected and that the vtab that any delays in resolution are corrected and that the vtab
is present. */ is present. */
ts = expr->symtree->n.sym->ts; declared = expr->ts.u.derived;
declared = ts.u.derived;
c = gfc_find_component (declared, "_vptr", true, true); c = gfc_find_component (declared, "_vptr", true, true);
if (c->ts.u.derived == NULL) if (c->ts.u.derived == NULL)
c->ts.u.derived = gfc_find_derived_vtab (declared); c->ts.u.derived = gfc_find_derived_vtab (declared);
...@@ -5895,6 +5893,7 @@ resolve_typebound_subroutine (gfc_code *code) ...@@ -5895,6 +5893,7 @@ resolve_typebound_subroutine (gfc_code *code)
/* Use the generic name if it is there. */ /* Use the generic name if it is there. */
name = name ? name : code->expr1->value.function.esym->name; name = name ? name : code->expr1->value.function.esym->name;
code->expr1->symtree = expr->symtree; code->expr1->symtree = expr->symtree;
code->expr1->ref = gfc_copy_ref (expr->ref);
expr->symtree->n.sym->ts.u.derived = declared; expr->symtree->n.sym->ts.u.derived = declared;
gfc_add_vptr_component (code->expr1); gfc_add_vptr_component (code->expr1);
gfc_add_component_ref (code->expr1, name); gfc_add_component_ref (code->expr1, name);
......
2011-01-31 Janus Weil <janus@gcc.gnu.org>
PR fortran/47463
* gfortran.dg/typebound_assignment_1.f03: New.
2011-01-31 Jakub Jelinek <jakub@redhat.com> 2011-01-31 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/47538 PR tree-optimization/47538
......
! { dg-do compile }
!
! PR 47463: [OOP] ICE in gfc_add_component_ref
!
! Contributed by Rich Townsend <townsend@astro.wisc.edu>
module hydro_state
type :: state_t
contains
procedure :: assign
generic :: assignment(=) => assign
end type state_t
contains
subroutine assign (this, that)
class(state_t), intent(inout) :: this
class(state_t), intent(in) :: that
end subroutine assign
end module hydro_state
module hydro_flow
use hydro_state
type :: flow_t
class(state_t), allocatable :: st
end type flow_t
contains
subroutine init_comps (this, st)
class(flow_t), intent(out) :: this
class(state_t), intent(in) :: st
allocate(state_t :: this%st)
this%st = st
end subroutine init_comps
end module hydro_flow
! { dg-final { cleanup-modules "hydro_state hydro_flow" } }
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