===================================================================
*************** resolve_typebound_static (gfc_expr* e, g
e->ref = NULL;
e->value.compcall.actual = NULL;
+ /* If we find a deferred typebound procedure, check for derived types
+ that an over-riding typebound procedure has not been missed. */
+ if (e->value.compcall.tbp->deferred
+ && e->value.compcall.name
+ && !e->value.compcall.tbp->non_overridable
+ && e->value.compcall.base_object
+ && e->value.compcall.base_object->ts.type == BT_DERIVED)
+ {
+ gfc_symtree *st;
+ gfc_symbol *derived;
+
+ /* Use the derived type of the base_object. */
+ derived = e->value.compcall.base_object->ts.u.derived;
+ st = NULL;
+
+ /* Look for the typebound procedure 'name'. */
+ if (derived->f2k_derived && derived->f2k_derived->tb_sym_root)
+ st = gfc_find_symtree (derived->f2k_derived->tb_sym_root,
+ e->value.compcall.name);
+
+ /* Now find the specific name in the derived type namespace. */
+ if (st && st->n.tb && st->n.tb->u.specific)
+ gfc_find_sym_tree (st->n.tb->u.specific->name,
+ derived->ns, 1, &st);
+ if (st)
+ *target = st;
+ }
return SUCCESS;
}
===================================================================
***************
! { dg-do run }
! PR46328 - complex expressions involving typebound operators of class objects.
+ ! PR48946 - complex expressions involving typebound operators of derived types.
!
module field_module
implicit none
*************** end module
program main
use i_field_module
implicit none
! class(i_field) ,allocatable :: u
! allocate (u, source = i_field (99))
!
! u = u*2.
! u = (u*2.0*4.0) + u*4.0
! u = u%multiply_real (2.0)*4.0
! u = i_multiply_real (u, 2.0) * 4.0
!
! select type (u)
! type is (i_field); if (u%i .ne. 152064) call abort
! end select
end program
! { dg-final { cleanup-modules "field_module i_field_module" } }
program main
use i_field_module
implicit none
! call check_class_tbos
! call check_derived_type_tbos
! contains
! subroutine check_class_tbos
! class(i_field) ,allocatable :: u
! allocate (u, source = i_field (99))
! u = u*2.
! u = (u*2.0*4.0) + u*4.0
! u = u%multiply_real (2.0)*4.0
! u = i_multiply_real (u, 2.0) * 4.0
! select type (u)
! type is (i_field); if (u%i .ne. 152064) call abort
! end select
! deallocate (u)
! end subroutine
! subroutine check_derived_type_tbos
! type(i_field) ,allocatable :: u
! allocate (u, source = i_field (99))
! u = u*2.
! u = (u*2.0*4.0) + u*4.0
! u = u%multiply_real (2.0)*4.0
! u = i_multiply_real (u, 2.0) * 4.0
! if (u%i .ne. 152064) call abort
! deallocate (u)
! end subroutine
end program
! { dg-final { cleanup-modules "field_module i_field_module" } }