diff mbox

[Fortran,Regression] PR 48059: ICE in in gfc_conv_component_ref: character function of extended type

Message ID AANLkTikNh=kEXum+n1skAGieLAEZYJeujXhz3oo++r-W@mail.gmail.com
State New
Headers show

Commit Message

Janus Weil March 12, 2011, 11:16 a.m. UTC
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  <janus@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  <janus@gcc.gnu.org>

	PR fortran/48059
	* gfortran.dg/class_41.f03: New.

Comments

Paul Richard Thomas March 12, 2011, 4:09 p.m. UTC | #1
Janus,

> The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?
>

Yes, as discussed off-list, it looks OK to me.  Get it committed asap!

Thanks for the patch

Paul


>
>
> 2011-03-12  Janus Weil  <janus@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  <janus@gcc.gnu.org>
>
>        PR fortran/48059
>        * gfortran.dg/class_41.f03: New.
>
Jerry DeLisle March 12, 2011, 6:52 p.m. UTC | #2
On 03/12/2011 03:16 AM, Janus Weil wrote:
> 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?
>

Yes, thanks for patch!

Jerry
Janus Weil March 12, 2011, 7:16 p.m. UTC | #3
>> The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?
>>
>
> Yes, as discussed off-list, it looks OK to me.  Get it committed asap!

Thanks. Committed as r170906.

Cheers,
Janus
diff mbox

Patch

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.  */