https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107000

--- Comment #18 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to anlauf from comment #14)
> 
> We could walk through the elements of each array passed to reduce_binary
> and check the types of the elements there, or do this check in a somewhat
> more clever way than in the patch attached to comment#3.
> 
> This patch tried to perform checks in reduce_binary_ac, but I was not happy
> with that particular implementation.
> 
> When looping over the elements, we currently have
> 
>       gfc_simplify_expr (c->expr, 0);
> 
>       if (c->expr->expr_type == EXPR_CONSTANT)
>         rc = eval (c->expr, op2, &r);
>       else
>       rc = reduce_binary_ac (eval, c->expr, op2, &r);
> 
> and do not handle the case that c->expr->ts.type == BT_UNKNOWN.
> Should we return sth. like rc = ARITH_INCOMMENSURATE, except that it is
> not array .op. array?

Well, a new return code seems better (ARITH_INVALID_TYPE ?).
I think it's better to move the check to the various gfc_arith_times,
gfc_arith_plus, gfc_arith_concat etc, because only those functions know what
type is appropriate and what is not.
Admittedly BT_UNKNOWN is probably never appropriate, and the check could be
done in reduce_binary_ac, but then it should be in reduce_binary_ca,
reduce_binary_aa and reduce_unary as well.
Then what's missing is a goto runtime in eval_intrinsic if evaluation returns
ARITH_INVALID_TYPE.
That's the first solution.

Reply via email to