[Patch, Fortran] SELECT TYPE via ASSOCIATE
Janus Weil
janus@gcc.gnu.org
Thu Aug 26 14:47:00 GMT 2010
Hi Daniel,
> the attached patch fixes ASSOCIATE for polymorphic values and switches the
> current implementation of SELECT TYPE to using ASSOCIATE internally.
thanks for working on this. I only had a glance at your patch, but
what I've seen looks good so far. Just some comments ...
> As a side-effect, this fixes the "double-free" PRs 44047 and 45384.
Ok. You told me before that you don't do anything special to prevent
these double free issues with ASSOCIATE. Can you explain to me how
your patch actually fixes these? I'd just like to understand it.
One difference I observed in the dump of PR 45384 (comment #3) is that
the old version had:
struct class$d_base_sparse_mat_a aa;
while with your patch one gets:
struct class$d_base_sparse_mat_a * aa;
I.e. one now has a pointer to a class container. This is a thing we
usually don't have in the OOP implementation, not even for
class(...), pointer :: x
since the pointer attribute is propagated to the $data component of
the class container, and the container itself always appears as
non-pointer. Therefore I think it might be better to stick with the
old non-pointer declaration. However, the pointer might just be the
reason that auto-deallocation does not happen. Right?
> I also think
> that the still missing piece (comment #3) of PR 44044 will be fixed when the
> testing for variable definition contexts in ASSOCIATE is extended (but so
> far the problem is still not detected).
Yes, can be done later.
> Regtested on GNU/Linux-x86-32. The only failure was bessel_7.f90, which
> goes away when I increase the tolerance according to
> http://gcc.gnu.org/ml/fortran/2010-08/msg00308.html. Ok for trunk?
Pretty much ok from my side, except for the points mentioned above.
Btw, for select_type_13.f03 you might wanna give credit to Salvatore
instead of me, since it's basically his test case (and he puts a lot
of effort into testing gfortran, so he very much deserved to be
mentioned).
Cheers,
Janus
> 2010-08-26 Daniel Kraft <d@domob.eu>
>
> PR fortran/38936
> PR fortran/44047
> PR fortran/45384
> * gfortran.h (struct gfc_association_list): New flag `dangling'.
> (gfc_build_block_ns): Declared here...
> * parse.h (gfc_build_block_ns): ...instead of here.
> * trans.h (gfc_process_block_locals): Expect additionally the
> gfc_association_list of BLOCK (if present).
> * match.c (select_type_set_tmp): Create sym->assoc for temporary.
> * symbol.c (gfc_free_symbol): Free a dangling association-list.
> * resolve.c (resolve_variable): Only check for invalid *array*
> references on associate-names.
> (resolve_assoc_var): New method with code previously in
> resolve_symbol.
> (resolve_select_type): Use association to give the selector and
> temporaries their values instead of ordinary assignment.
> (resolve_fl_var_and_proc): Allow CLASS associate-names.
> (resolve_symbol): Use new `resolve_assoc_var' instead of inlining
> here.
> * trans-stmt.c (gfc_trans_block_construct): Pass association-list
> to `gfc_process_block_locals' to match new interface.
> * trans-decl.c (gfc_get_symbol_decl): Don't defer associate-names
> here automatically.
> (gfc_process_block_locals): Defer them rather here when linked to
> from the BLOCK's association list.
>
> 2010-08-26 Daniel Kraft <d@domob.eu>
>
> PR fortran/38936
> PR fortran/44047
> PR fortran/45384
> * gfortran.dg/associate_8.f03: New test.
> * gfortran.dg/select_type_13.f03: New test.
> * gfortran.dg/select_type_14.f03: New test.
More information about the Fortran
mailing list