[Patch, fortran] PR41600 - [OOP] SELECT TYPE with associate-name => exp: Arrays not supported
Paul Richard Thomas
paul.richard.thomas@gmail.com
Sun Mar 18 20:09:00 GMT 2012
Dear All,
Please find attached a fix for PR41600 plus some. It is reasonably
straightforward but the following should be noted:
(i) gfc_get_vptr_from_expr exploits that seeming fact that tracing
back any class expression through TREE_OPERAND 0 eventually gets one
back to the class expression. I will root through the various
functions that operate on class objects to remove the front-endery
that does the same thing but in a much more cumbersome way;
(ii) GFC_CLASS_TYPE_P has been introduced, as it should have been in
the first place :-( Its first use is in (i);
(iii) The error that is thrown in resolve_assoc_var is necessary
because wrong code is produced at the moment since the size of the
declared type, rather than the dynamic type, is used for allocation of
the temporary. The necessary machinery is in place to fix this and I
will do so soon; and
(iv) select_type_set_tmp was broken up to make the logic more
transparent. The result is only a little longer than it would have
been without the calls to select_derived_set_tmp and
select_class_set_tmp.
There is quite a lot of retrospective tidying up to do using (i) and (ii)!
Bootstraps and regtests on FC9/x86_64 - OK for trunk?
Cheers
Paul
2012-03-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/41600
* trans-array.c (build_array_ref): New static function.
(gfc_conv_array_ref, gfc_get_dataptr_offset): Call it.
* trans-expr.c (gfc_get_vptr_from_expr): New function.
(gfc_conv_derived_to_class): Add a new argument for a caller
supplied vptr and use it if it is not NULL.
(gfc_conv_procedure_call): Add NULL to call to above.
symbol.c (gfc_is_associate_pointer): Return true if symbol is
a class object.
* trans-stmt.c (trans_associate_var): Handle class associate-
names.
* expr.c (gfc_get_variable_expr): Supply the array-spec if
possible.
* trans-types.c (gfc_typenode_for_spec): Set GFC_CLASS_TYPE_P
for class types.
* trans.h : Add prototypes for gfc_get_vptr_from_expr and
gfc_conv_derived_to_class. Define GFC_CLASS_TYPE_P.
* resolve.c (resolve_variable): For class arrays, ensure that
the target expression has all the necessary _data references.
(resolve_assoc_var): Throw a "not yet implemented" error for
class array selectors that need a temporary.
* match.c (copy_ts_from_selector_to_associate,
select_derived_set_tmp, select_class_set_tmp): New functions.
(select_type_set_tmp): Call one of last two new functions.
(gfc_match_select_type): Copy_ts_from_selector_to_associate is
called if associate-name is typed.
2012-03-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/41600
* gfortran.dg/select_type_26.f03 : New test.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: submit.diff
Type: text/x-diff
Size: 25791 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20120318/0334e810/attachment.bin>
More information about the Fortran
mailing list