This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Fortran, DRAFT patch] PR 46321 - [OOP] Polymorphic deallocation


Dear all,

in attachment the new draft which also supports the polymorphic
deallocation via INTENT(OUT). Tomorrow I'll try to realize a draft for
the deallocation at the end of the scope.

Regards

2012/6/12 Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>:
> I don't know if there's already a PR but I get an ICE compiling this
> with a non-patched version. If x is not an array everything goes ok.
>
> 2012/6/11 Tobias Burnus <burnus@net-b.de>:
>> On 06/11/2012 11:24 AM, Alessandro Fanfarillo wrote:
>>>
>>> gfortran.dg/coarray/poly_run_3.f90
>>
>>
>> That one fails because I for forgot that se.expr in gfc_trans_deallocate
>> contains the descriptor and not the pointer to the data. That's fixed by:
>>
>> ? ? ? ? ?tmp = se.expr;
>> ? ? ? ? ?if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (tmp)))
>> ? ? ? ? ? ?{
>> ? ? ? ? ? ? ?tmp = gfc_conv_descriptor_data_get (tmp);
>> ? ? ? ? ? ? ?STRIP_NOPS (tmp);
>>
>> ? ? ? ? ? ?}
>> ? ? ? ? ?tmp = ?fold_build2_loc (input_location, NE_EXPR, boolean_type_node,
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tmp, build_int_cst (TREE_TYPE (tmp), 0));
>>
>> However, it still fails for the
>>
>> type t
>> ?integer, allocatable :: comp
>> end type t
>> contains
>> ?subroutine foo(x)
>> ? ?class(t), allocatable, intent(out) :: x(:)
>> ?end subroutine
>> end
>>
>> (The intent(out) causes automatic deallocation.) The backtrace does not
>> really point to some code which the patch touched; it shouldn't be affected
>> by the class.c changes and gfc_trans_deallocate does not seem to be entered.
>>
>> While I do not immediately see why it fails, I wonder whether it is due to
>> the removed "else if ... BT_CLASS)" case in
>> gfc_deallocate_scalar_with_status. In any case, the change to
>> gfc_trans_deallocate might be also needed for
>> gfc_deallocate_scalar_with_status. At least, automatic deallocation (with
>> intent(out) or when leaving the scope) does not seem to go through
>> gfc_trans_deallocate but only through gfc_deallocate_scalar_with_status.
>>
>> Tobias

Attachment: patch_Deallocate_INTENTOUT.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]