[Patch, Fortran, OOP] PR 44541: wrong code for polymorphic variable with INTENT(OUT)/Alloc w/ MOLD
Janus Weil
janus@gcc.gnu.org
Wed Sep 1 09:53:00 GMT 2010
Hi all,
this patch implements the polymorphic default initialization of CLASS
variables, which can happen in two situations:
1) polymorphic dummy with INTENT(OUT)
2) ALLOCATE(x, MOLD=y) where x and y are polymorphic.
In these cases we have to initialize with the default initializer of a
dynamic type which is not known at compile time. To implement this I
added a new pointer component called '$def_init' to the vtable, which
is being initialized to point to a default-initalized variable of the
respective type. This is then used for the default-initialization of
CLASS variables (via memcpy). For case #1 this happens in
gfc_trans_class_init_assign, for case #2 in gfc_trans_allocate (I had
to move the handling of default initialization on allocation from
resolution to translation stage).
The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?
Cheers,
Janus
2010-09-01 Janus Weil <janus@gcc.gnu.org>
PR fortran/44541
* class.c (gfc_find_derived_vtab): Add component '$def_init'.
* resolve.c (resolve_allocate_expr): Defer handling of default
initialization to 'gfc_trans_allocate'.
(apply_default_init,resolve_symbol): Handle polymorphic dummies.
(resolve_fl_derived): Suppress error messages for vtypes.
* trans-stmt.c (gfc_trans_allocate): Handle initialization via
polymorphic MOLD expression.
* trans-expr.c (gfc_trans_class_init_assign): Now only used for
dummy initialization.
2010-09-01 Janus Weil <janus@gcc.gnu.org>
PR fortran/44541
* gfortran.dg/allocate_alloc_opt_10.f90: Extended.
* gfortran.dg/class_dummy_1.f03: New.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr44541.diff
Type: application/octet-stream
Size: 9251 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20100901/a172ea71/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: class_dummy_1.f03
Type: application/octet-stream
Size: 637 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20100901/a172ea71/attachment-0001.obj>
More information about the Fortran
mailing list