This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Polymorphic deep copy (aka PR46174)
- From: Tobias Burnus <burnus at net-b dot de>
- To: Janus Weil <janus at gcc dot gnu dot org>
- Cc: gfortran <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 05 Nov 2010 11:41:18 +0100
- Subject: Re: [RFC] Polymorphic deep copy (aka PR46174)
- References: <AANLkTi=W6KQY_KRMO8KjwoSfdkcmn1o5Mysv0+p9sdXk@mail.gmail.com> <4CD0F19B.7020402@frontier.com> <AANLkTi=p9PEX+WOb13VOLTYpUSLvL1_SRHA5MT6NPyOU@mail.gmail.com> <AANLkTi=gG1zGU+4UT4iC=a4jSz_Y+=V1AEvj7ytUzWEj@mail.gmail.com> <4CD3AC9D.3090205@net-b.de> <AANLkTin6dorZsKmwvPdrFTs=x4pf-TwXvsRMjt=2wrh3@mail.gmail.com>
On 11/05/2010 10:56 AM, Janus Weil wrote:
I think the problem was the following: The assigment in copy$foo, which is just
dst = src !!! both 'dst' and 'src' being TYPE(foo)
was falsely transformed into a call to the typebound assignment
operator, although no polymorphic pass-object was present. I fixed
this by modifying gfc_extend_assign in interface.c.
I am not 100% sure about the code in gfc_extend_assign. In particular, I
wonder whether
if (lhs->ts.type == BT_CLASS)
{
should not also have "|| lhs->ts.type == BT_TYPE". Though, that probably
would just undo what you did in the patch.
I think the following program is valid and now rejected with your patch:
------------------------------------
module m
type t
integer :: ij
contains
procedure :: my_assign
generic :: assignment(=) => my_assign
end type t
contains
SUBROUTINE my_assign (dest, from)
CLASS(t), INTENT(INOUT) :: dest
integer, INTENT(IN) :: from
dest%ij = -from
END SUBROUTINE
end module m
use m
type(t) :: x
x = 4
print *, x%ij
end
------------------------------------
Tobias