On Wed, Sep 18, 2024 at 02:50:39PM -0600, Sandra Loosemore wrote: > Here's the revised patch, covering both restrictions. OK to commit?
Thanks. > + /* Each trait-property can only be specified once in a trait-selector > + other than the construct selector set. FIXME: only handles > + name-list properties, not clause-list properties, since the > + "requires" selector is not implemented yet (PR 113067). */ > + if (tss_code != OMP_TRAIT_SET_CONSTRUCT) > + for (tree p1 = OMP_TS_PROPERTIES (ts); p1; p1 = TREE_CHAIN (p1)) > + { > + if (OMP_TP_NAME (p1) != OMP_TP_NAMELIST_NODE) > + break; > + const char *n1 = omp_context_name_list_prop (p1); > + if (!n1) > + continue; > + for (tree p2 = TREE_CHAIN (p1); p2; p2 = TREE_CHAIN (p2)) > + { > + const char *n2 = omp_context_name_list_prop (p2); > + if (!n2) > + continue; > + if (!strcmp (n1, n2)) > + { > + error_at (loc, > + "trait-property %qs specified more " > + "than once in %qs selector", > + n1, OMP_TS_NAME (ts)); > + return error_mark_node; > + } > + } > + } This is O(n^2) in number of properties, but let's hope people are sane and don't try: #define A(x) n#x, #define B(x) A(x##0) A(x##1) A(x##2) A(x##3) A(x##4) A(x##5) A(x##6) A(x##7) A(x##8) A(x##9) #define C(x) B(x##0) B(x##1) B(x##2) B(x##3) B(x##4) B(x##5) B(x##6) B(x##7) B(x##8) B(x##9) #define D(x) C(x##0) C(x##1) C(x##2) C(x##3) C(x##4) C(x##5) C(x##6) C(x##7) C(x##8) C(x##9) #define E(x) D(x##0) D(x##1) D(x##2) D(x##3) D(x##4) D(x##5) D(x##6) D(x##7) D(x##8) D(x##9) isa(E(1), avx512f) or something similar. Otherwise, we'd need a hash table if the list is longer than say 20 entries (of course, that could be detected in the first inner loop and switch for that to the different implementation). > + > + /* Check for unknown properties. */ > if (omp_ts_map[ts_code].valid_properties == NULL) > continue; > - Why? Otherwise LGTM. Jakub