This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran] PR18022 - assignments of the kind x(:)%i = f(y(:))


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]