Hi all, the attached patch fixes the PR in the subject line. The problem was the following: During the interface mapping for a procedure call we need to take special care of polymorphic arguments, since the type of the actual argument can differ from the type of the formal argument. Therefore we need to replace the base type of component references by the actual type (in particular to get parent references right).
The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk? Cheers, Janus 2011-03-12 Janus Weil <ja...@gcc.gnu.org> PR fortran/48059 * trans-expr.c (gfc_apply_interface_mapping_to_expr): Replace base type for polymorphic arguments. 2011-03-12 Janus Weil <ja...@gcc.gnu.org> PR fortran/48059 * gfortran.dg/class_41.f03: New.
Index: gcc/fortran/trans-expr.c =================================================================== --- gcc/fortran/trans-expr.c (revision 170879) +++ gcc/fortran/trans-expr.c (working copy) @@ -2247,6 +2247,10 @@ gfc_apply_interface_mapping_to_expr (gfc_interface expr->symtree = sym->new_sym; else if (sym->expr) gfc_replace_expr (expr, gfc_copy_expr (sym->expr)); + /* Replace base type for polymorphic arguments. */ + if (expr->ref && expr->ref->type == REF_COMPONENT + && sym->expr && sym->expr->ts.type == BT_CLASS) + expr->ref->u.c.sym = sym->expr->ts.u.derived; } /* ...and to subexpressions in expr->value. */
class_41.f03
Description: Binary data