Le 28/02/2022 à 15:27, Kwok Cheung Yeung a écrit :
On 28/02/2022 2:07 pm, Jakub Jelinek wrote:
(...)
Don't we usually test instead || (*expr)->rank != 0 when testing for
scalars?
(...)
So (*expr)->rank is 0 here even with an array. I'm not sure why - is
rank updated later, or did we forget to call something on the event
handle expression?
Testing against n->sym->as for an array check has been used elsewhere in
openmp.cc, to prevent reductions against arrays in OpenACC in
resolve_omp_clauses.
I can’t tell what openmp requires; it depends on your needs.
Checking sym->as captures array variables which may include scalar
expressions (arr(10) is a scalar expression even if arr is an array
variable), while checking expr->rank only capture array expression,
including scalar variable with array subcomponent (scal%array_comp(:) is
an array expression, even if scal is a scalar variable).
gfc_resolve_expr, through gfc_expression_rank takes care of properly
setting expr->rank.
If the check is done at resolution stage (somewhere in
resolve_omp_clauses I guess?), the rank should be set.
I hope it helps.