On Wed, 2 Nov 2022 12:58:37 +0100 Jakub Jelinek via Fortran <fortran@gcc.gnu.org> wrote:
> On Tue, Nov 01, 2022 at 09:50:38PM +0000, Julian Brown wrote: > > > I think we should figure out when we should temporarily disable > > > parser->omp_array_section_p = false; > > > and restore it afterwards to a saved value. E.g. > > > cp_parser_lambda_expression seems like a good candidate, the fact > > > that OpenMP array sections are allowed say in map clause doesn't > > > mean they are allowed inside of lambdas and it would be > > > especially hard when the lambda is defining a separate function > > > and the search for OMP_ARRAY_SECTION probably wouldn't be able to > > > discover those. Other spots to consider might be statement > > > expressions, perhaps type definitions etc. > > > > I've had a go at doing this -- several expression types now forbid > > array-section syntax (see new "bad-array-section-*" tests added). > > I'm afraid my C++ isn't quite up to figuring out how it's possible > > to define a type inside an expression (inside a map clause) if we > > forbid lambdas and statement expressions though -- can you give an > > example? > > But we can't forbid lambdas inside of the map clause expressions, > they are certainly valid in OpenMP, and IMNSHO shouldn't disallow > statement expressions, people might not even know they use a > statement expression, they could just use some standard macro which > uses a statement expression under the hood. Though your testcases > look good. I meant "forbid array sections within lambdas and statement expressions" -- FAOD, does that seem reasonable? Technically it might not be that hard to support e.g. a statement expression with an array section on the final expression, but that doesn't work at the moment. Maybe a follow-on patch could support that if we want it? I'll take a look at addressing your other review comments, thanks! Cheers, Julian