Hello I have updated the patch to catch array elements and structure components as additional checks, in addition to checking that the variable is a scalar. The check has been moved to the end of resolve_omp_clauses as it is more appropriate there. This gets rid of the additional 'Unexpected !$OMP END TASK statement' error, since the type error is now caught after the matching phase. Coarrays (with the testcases in pr104131-2.f90) can be dealt with in a separate patch. Is this part okay for trunk? Thanks Kwok On 01/03/2022 3:37 pm, Mikael Morin wrote: > So, if I try to sum up what has been gathered in this thread: > >  - pr104131.f90 is invalid, as x is not scalar. >    Checks are better done in resolve_omp_clauses after a call >    to gfc_resolve_expr. >    Checking expr->sym->attr.dimension seems to cover more cases than >    expr->rank > 0. > >  - pr104131-2.f90 is valid and should be accepted. > >  - Some other cases should be rejected, including x[1] (coindexed >    variable), x(1) (array element), x%comp (structure component). > > Is that correct? Anything else? > > Regarding the expr->rank vs expr->sym->attr.dimension controversy, my > take is that it should stick to the error message.  Use expr->rank is > the error is about scalar vs array, use expr->sym->attr.dimension if > it’s about subobject-ness of an array variable. > > Coming back to the PR, the ICE backtraces for pr104131.f90 and > pr104131-2.f90 are different and should probably be treated separatedly. > I don’t know how difficult the bullet 2 above would be, but bullet 1 and > 3 seem quite doable.