This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] PR18022 - assignments of the kind x(:)%i = f(y(:))
- From: Richard Sandiford <richard at codesourcery dot com>
- To: Paul Thomas <paulthomas2 at wanadoo dot fr>
- Cc: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>, "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, patch <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 14 Oct 2005 07:55:19 +0100
- Subject: Re: [Patch, fortran] PR18022 - assignments of the kind x(:)%i = f(y(:))
- References: <434D8D18.7000201@wanadoo.fr>
Paul Thomas <paulthomas2@wanadoo.fr> writes:
> *************** gfc_trans_assignment (gfc_expr * expr1, 2648,2653 ****
> --- 2648,2668 ----
> tree tmp;
> stmtblock_t block;
> stmtblock_t body;
> + gfc_ref * ref;
> + int seen_array_ref;
> +
> + /* Before even thinking about calling gfc_trans_arrayfunc_assign,
> + check that no component references appear after any array
> + references. This is needed because we do not have the means to
> + span any arbitrary stride with an array descriptor. */
> + seen_array_ref = 0;
> + for (ref = expr1->ref; ref; ref = ref->next)
> + {
> + if (ref->type == REF_ARRAY)
> + seen_array_ref= 1;
> + else if (ref->type == REF_COMPONENT && seen_array_ref)
> + goto scalarize;
> + }
>
> /* Special case a single function returning an array. */
> if (expr2->expr_type == EXPR_FUNCTION && expr2->rank > 0)
> *************** gfc_trans_assignment (gfc_expr * expr1, 2657,2662 ****
> --- 2672,2679 ----
> return tmp;
> }
>
> + scalarize:
> +
> /* Assignment of the form lhs = rhs. */
> gfc_start_block (&block);
Would it be better to add this check to gfc_trans_arrayfunc_assign
instead? It would avoid the GOTO -- you'd just return NULL instead --
and plenty of other checks are done there already.
Richard