On Fri, Apr 28, 2023 at 05:22:53PM -0600, Sandra Loosemore wrote: > OpenMP 5.0 removed the restriction that multiple collapsed loops must > be perfectly nested, allowing "intervening code" (including nested > BLOCKs) before or after each nested loop. In GCC this code is moved > into the inner loop body by the respective front ends. > > This patch changes the C++ front end to use recursive descent parsing > on nested loops within an "omp for" construct, rather than an > iterative approach, in order to preserve proper nesting of compound > statements. Preserving cleanups (destructors) for class objects > declared in intervening code and loop initializers complicates moving > the former into the body of the loop; this is handled by parsing the > entire construct before reassembling any of it.
What I wrote about the C patch applies mostly about this patch too, so I won't review it in detail until the review comments are handled in both, just would like to note that while C (so far) only supports #pragma syntax for OpenMP, C++ also supports the attribute syntax (see e.g. g++.dg/gomp/attrs-*.C testcases). So, e.g. the no OpenMP constructs in intervening code restriction applies also to the attribute syntax and needs to be tested for it. It might work without too many changes because the attribute syntax is handled by rewriting it essentially into pragma syntax and letting the parser parse it like that. Of course, it will matter more for the tile/unroll patch when used together your patch, when it will need to allow the task generating constructs for the moreloops cases. > libgomp/ChangeLog > * testsuite/libgomp.c++/imperfect-class-1.C : New. > * testsuite/libgomp.c++/imperfect-class-2.C : New. > * testsuite/libgomp.c++/imperfect-class-3.C : New. > * testsuite/libgomp.c++/imperfect-destructor.C : New. > * testsuite/libgomp.c++/imperfect-template-1.C : New. > * testsuite/libgomp.c++/imperfect-template-2.C : New. > * testsuite/libgomp.c++/imperfect-template-3.C : New. Formatting, there shouldn't be space before : in ChangeLog entries. Jakub