http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48059
--- Comment #11 from janus at gcc dot gnu.org 2011-03-11 18:24:01 UTC ---
The patch in comment #8 induced a regression in module_read_2.f90, which is
fixed by the following update (we must only replace the base type, if the
actual argument is polymorphic!):
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. */
In this form the patch is free of testsuite regressions (on
x86_64-unknown-linux-gnu). Ok for trunk?