On Thu, Oct 22, 2015 at 07:47:01AM -0700, Cesar Philippidis wrote: > > But it is unclear from the parsing what from these is allowed: > > int v, w; > ... > gang(26) // equivalent to gang(num:26) > gang(v) // gang(num:v) > vector(length: 16) // vector(length: 16) > vector(length: v) // vector(length: v) > vector(16) // vector(length: 16) > vector(v) // vector(length: v) > worker(num: 16) // worker(num: 16) > worker(num: v) // worker(num: 16) > worker(16) // worker(num: 16) > worker(v) // worker(num: 16) > gang(16, 24) // technically gang(num:16, num:24) is acceptable but it > // should be an error > gang(v, w) // likewise > gang(static: 16, num: 5) // gang(static: 16, num: 5) > gang(static: v, num: w) // gang(static: v, num: w) > gang(num: 5, static: 4) // gang(num: 5, static: 4) > gang(num: v, static: w) // gang(num: v, static: w) > > Also note that the static argument can accept '*'. > > > and if the length: or num: part is really optional, then > > int length, num; > > vector(length) > > worker(num) > > gang(num, static: 6) > > gang(static: 5, num) > > should be also accepted (or subset thereof?). > > Interesting question. The spec is unclear. It defines gang, worker and > vector as follows in section 2.7 in the OpenACC 2.0a spec: > > gang [( gang-arg-list )] > worker [( [num:] int-expr )] > vector [( [length:] int-expr )] > > where gang-arg is one of: > > [num:] int-expr > static: size-expr > > and gang-arg-list may have at most one num and one static argument, > and where size-expr is one of: > > * > int-expr > > So I've interpreted that as a requirement that length and num must be > followed by an int-expr, whatever that is.
My reading of the above is that vector(length) is equivalent to vector(length: length) and worker(num) is equivalent to vector(num: num) etc. Basically, neither length nor num aren't reserved identifiers, so you can use them for variable names, and if vector(v) is equivalent to vector(length: v), then vector(length) should be equivalent to vector(length:length) or vector(length + 1) should be equivalent to vector(length: length+1) static is a keyword that can't start an integral expression, so I guess it is fine if you issue an expected : diagnostics after it. In any case, please add a testcase (both C and C++) which covers all these allowed variants (ideally one testcase) and rejected variants (another testcase with dg-error). This is still an easy case, as even the C FE has 2 tokens lookup. E.g. for OpenMP map clause where map (always, tofrom: x) means one thing and map (always, tofrom, y) another one (map (tofrom: always, tofrom, y)) I had to do quite ugly things to get around this. Jakub