http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48059

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |janus at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #8 from janus at gcc dot gnu.org 2011-03-11 15:39:20 UTC ---
(In reply to comment #7)
> > So, it wants to get at the a_type.length member, but applies the whole
> > thing to a b_type'd variable.
> 
> Yes, the base type in the reference is wrong. And the reason for this seems to
> be that it is not corrected in the interface mapping. I think we need to 
> extend
> 'gfc_apply_interface_mapping_to_ref' to set the correct base type for
> polymorphic arguments.

The following seems to do the trick (not regtested yet):

Index: trans-expr.c
===================================================================
--- trans-expr.c        (revision 170870)
+++ trans-expr.c        (working copy)
@@ -2247,6 +2247,9 @@ 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)
+         expr->ref->u.c.sym = sym->expr->ts.u.derived;
       }

       /* ...and to subexpressions in expr->value.  */

Reply via email to