[Patch,Fortran] reset dynamic type with MOVE_ALLOC (was: Re: [Patch, Fortran] Small patch for calls to gfc_deallocate_scalar_with_status)

Tobias Burnus burnus@net-b.de
Sun Dec 9 19:04:00 GMT 2012

Janus Weil wrote:
>> >The expr to al->expr change is to pass a BT_CLASS instead of a
>> >BT_DERIVED. And the NULL to gfc_lval_expr_from_sym change allows to access
>> >var->_vtab->_final for a BT_CLASS deferred variable.
> It seems that both of them will not have any effect right now, but are
> useful only as preparation for FINAL, right?

I think that's true. I wanted to claim that it also fixes the following, 
but it doesn't:

  class(t), allocatable :: a, b, c
  allocate (t2 :: a)
  call move_alloc (from=a, to=b)

"a" should not only be deallocated but same_type_as(a,c) should be true, 
i.e. one has to reset the "a->_vtab" pointer to the declared type.

A follow-up patch which fixes this is attached.

Build and regtested on x86-64-gnu-linux.
OK for the trunk?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: move_alloc-class-fix.diff
Type: text/x-patch
Size: 4843 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20121209/4e033c6c/attachment.bin>

More information about the Gcc-patches mailing list