* [Patch, Fortran, Regression] PR 48059: ICE in in gfc_conv_component_ref: character function of extended type
@ 2011-03-12 11:16 Janus Weil
2011-03-12 16:09 ` Paul Richard Thomas
2011-03-12 18:51 ` Jerry DeLisle
0 siblings, 2 replies; 4+ messages in thread
From: Janus Weil @ 2011-03-12 11:16 UTC (permalink / raw)
To: gfortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 766 bytes --]
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.
[-- Attachment #2: pr48059.diff --]
[-- Type: text/x-diff, Size: 653 bytes --]
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. */
[-- Attachment #3: class_41.f03 --]
[-- Type: application/octet-stream, Size: 664 bytes --]
! { dg-do compile }
!
! PR 48059: [4.6 Regression][OOP] ICE in in gfc_conv_component_ref: character function of extended type
!
! Contributed by Hans-Werner Boschmann <boschmann@tp1.physik.uni-siegen.de>
module a_module
type :: a_type
integer::length=0
end type a_type
type,extends(a_type) :: b_type
end type b_type
contains
function a_string(this) result(form)
class(a_type),intent(in)::this
character(max(1,this%length))::form
end function a_string
subroutine b_sub(this)
class(b_type),intent(inout),target::this
print *,a_string(this)
end subroutine b_sub
end module a_module
! { dg-final { cleanup-modules "a_module" } }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, Fortran, Regression] PR 48059: ICE in in gfc_conv_component_ref: character function of extended type
2011-03-12 11:16 [Patch, Fortran, Regression] PR 48059: ICE in in gfc_conv_component_ref: character function of extended type Janus Weil
@ 2011-03-12 16:09 ` Paul Richard Thomas
2011-03-12 19:17 ` Janus Weil
2011-03-12 18:51 ` Jerry DeLisle
1 sibling, 1 reply; 4+ messages in thread
From: Paul Richard Thomas @ 2011-03-12 16:09 UTC (permalink / raw)
To: Janus Weil; +Cc: gfortran, gcc-patches
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.
>
--
The knack of flying is learning how to throw yourself at the ground and miss.
--Hitchhikers Guide to the Galaxy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, Fortran, Regression] PR 48059: ICE in in gfc_conv_component_ref: character function of extended type
2011-03-12 11:16 [Patch, Fortran, Regression] PR 48059: ICE in in gfc_conv_component_ref: character function of extended type Janus Weil
2011-03-12 16:09 ` Paul Richard Thomas
@ 2011-03-12 18:51 ` Jerry DeLisle
1 sibling, 0 replies; 4+ messages in thread
From: Jerry DeLisle @ 2011-03-12 18:51 UTC (permalink / raw)
To: Janus Weil; +Cc: gfortran, gcc-patches
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch, Fortran, Regression] PR 48059: ICE in in gfc_conv_component_ref: character function of extended type
2011-03-12 16:09 ` Paul Richard Thomas
@ 2011-03-12 19:17 ` Janus Weil
0 siblings, 0 replies; 4+ messages in thread
From: Janus Weil @ 2011-03-12 19:17 UTC (permalink / raw)
To: Paul Richard Thomas; +Cc: gfortran, gcc-patches
>> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-12 19:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-12 11:16 [Patch, Fortran, Regression] PR 48059: ICE in in gfc_conv_component_ref: character function of extended type Janus Weil
2011-03-12 16:09 ` Paul Richard Thomas
2011-03-12 19:17 ` Janus Weil
2011-03-12 18:51 ` Jerry DeLisle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).