On Wed, Jan 08, 2020 at 09:14:10AM +0100, Tobias Burnus wrote: > Especially in light of the OpenMP 4.5's structure element mapping (for C/C++ > since GCC 7, for Fortran still unsupported), I had preferred some > consolidation like taking the last reference in that check instead of just > checking that the first reference is a whole array. Namely: > > --- a/gcc/fortran/trans-openmp.c > +++ b/gcc/fortran/trans-openmp.c > @@ -2498,3 +2498,6 @@ gfc_trans_omp_clauses (stmtblock_t *block, > gfc_omp_clauses *clauses, > - if (n->expr == NULL > - || (n->expr->ref->type == REF_ARRAY > - && n->expr->ref->u.ar.type == AR_FULL)) > + gfc_array_ref *array_ref = NULL; > + if (n->expr) > + for (gfc_ref *ref = n->expr->ref; ref; ref = ref->next) > + if (ref->type == REF_ARRAY) > + array_ref = &ref->u.ar; > + if (array_ref && array_ref->type == AR_FULL) > > I still believe believe that's a good/better approach.
With mixed REF_COMPONENT and REF_ARRAY, one can have var(:), or var2%comp(:) or var3(:)%comp, or var3%comp(:)%comp2 etc. and so the question is what exactly we want to handle in the first if and what in the other cases. If it should handle what it was originally meant to, i.e. just whole variables and treating full arrays therefore the same, that would be instead a loop through the refs like you have that would for REF_ARRAY with u.ar.type == AR_FULL just look through it and continue, but for anything else would break and then check if we got NULL ref. And something else should handle the other references, and that one needs to walk the ref chain and handle each REF_ARRAY or REF_COMPONENT in there. Jakub