Le 25/11/2021 à 22:52, Harald Anlauf a écrit :
>
> Motivated by your reasoning I tried gfc_reduce_init_expr. That attempt
> failed miserably (many regressions), and I think it is not right.
> Then I found that array sections posed a problem that wasn't detected
> before. gfc_simplify_expr seemed to be a better choice that makes more
> sense for the present situations and seems to work here. And it even
> detects many more invalid cases now than e.g. Intel ;-)
>
Great let’s go with that.
Can you set shape_is_constant just after the simplification?
That is
gfc_simplify_expr (shape, 0);
if (gfc_is_constant_expr (shape))
shape_is_const = true;
if (shape->expr_type == EXPR_ARRAY && shape_is_const)
...
This removes the need for multiple case initialization of shape_is_const
which I overlooked in my previous review.
And the EXPR_ARRAY vs EXPR_VARIABLE change becomes unneeded because the
simplification should produce an EXPR_ARRAY.