[Patch, fortran] PR24862 IO for arrays of derived type.
Tobias.Schlueter@Physik.Uni-Muenchen.DE
Tobias.Schlueter@Physik.Uni-Muenchen.DE
Thu Nov 17 20:26:00 GMT 2005
Quoting Janne Blomqvist <jblomqvi@cc.hut.fi>:
> my transfer_array patch that was committed about two months ago didn't
> handle IO for arrays of derived type correctly. This patch fixes it.
>
> The control flow in the new version is a bit convoluted, so I'd be
> happy to recieve suggestions on how to improve it.
WRT this hunk:
+ tmp = gfc_get_dtype (TREE_TYPE (se.expr));
+ if (((TREE_INT_CST_LOW (tmp) & GFC_DTYPE_TYPE_MASK)
+ >> GFC_DTYPE_TYPE_SHIFT) != GFC_DTYPE_DERIVED)
+ {
+ tmp = gfc_build_addr_expr (NULL, se.expr);
+ transfer_array_desc (&se, &expr->ts, tmp);
+ goto finish_block_label;
+ }
+ else
+ {
+ /* Cleanup the mess getting the descriptor caused. */
+ expr = code->expr;
+ ss = gfc_walk_expr (expr);
+ gfc_init_se (&se, NULL);
+ }
You could do away with the call to gfc_get_dtype and the subsequent if by saying
the following, mimicing the code in gfc_get_dtype:
if (TREE_TYPE (gfc_get_element_type (se.expr)) == RECORD_TYPE)
Since we usually abstract away the detailed middle-end types, this should
probably be made a predicate function, such as gfc_is_derived_type (tree).
Apart from that the patch looks fine.
- Tobi
More information about the Fortran
mailing list