> Hi Julian, > > I had a first quick lock at this patch, I should have a closer look > later. However, I stumbled over the following: > > On 20.10.22 18:14, Julian Brown wrote: > > typedef struct gfc_symbol > > { > > ... > > struct gfc_symbol *old_symbol; > > > > unsigned mark:1, comp_mark:1, data_mark:1, dev_mark:1, > > gen_mark:1; unsigned reduc_mark:1, gfc_new:1; > > > > struct gfc_symbol *tlink; > > > > unsigned equiv_built:1; > > ... > I know that this was the case before, but can you move the mark:1 etc. > after 'tlink'? In that case all bitfields are grouped together. If I > have not miscounted, we have currently 7 bits before and 9 bits after > 'tlink' and grouping them together reduced pointless padding. > > * * * > > + else if (n->sym->mark) > > + gfc_error ("Symbol %qs present on both data and map clauses " > > + "at %L", n->sym->name, &n->where); > > I wonder whether that also rejects the following – which seems to be > valid. The 'map' goes to 'target' and the 'firstprivate' to > 'parallel', cf. OpenMP 5.2, "17.2 Clauses on Combined and Composite > Constructs", [340:3-4 & 12-14]. (BTW: While some fixes went into 5.1 > regarding this section, a likewise wording is already in 5.0.) > > (Testing showed: it give an ICE without the patch and an error with.) ...and this patch avoids the error for combined directives, and reorders the gfc_symbol bitfields. -- This patch adds duplicate checking for OpenMP "map" clauses, taking some cues from the implementation for C in c-typeck.cc:c_finish_omp_clauses (and similar for C++). In addition to the existing use of the "mark" and "comp_mark" bitfields in the gfc_symbol structure, the patch adds several new bits handling duplicate checking within various categories of clause types. If "mark" is being used for map clauses, we need to use different bits for other clauses for cases where "map" and some other clause can refer to the same symbol (e.g. "map(n) shared(n)"). This version of the patch avoids flagging variables that are listed on both map and firstprivate clauses when they are on a combined directive, as they get moved to separate nested directives later (see previous patch in series). Tested with offloading to NVPTX alongside previous patch (and dependencies). OK? 2022-12-06 Julian Brown gcc/fortran/ PR fortran/107214 * gfortran.h (gfc_symbol): Add data_mark, dev_mark, gen_mark and reduc_mark bitfields. * openmp.cc (resolve_omp_clauses): Use above bitfields to improve duplicate clause detection. gcc/testsuite/ PR fortran/107214 * gfortran.dg/gomp/pr107214.f90: New test.