On Tue, Aug 17, 2021 at 02:55:56PM +0200, Tobias Burnus wrote: > On 17.08.21 09:47, Jakub Jelinek wrote: > > This patch implements the OpenMP 5.1 scope construct, which is similar > > to worksharing constructs in many regards, but isn't one of them. > > And the attached patch does the same for Fortran. > > I took the opportunity to convert some additional C/C++ testcases to Fortran > ones. > > That latter is rather mechanical but took surprisingly much longer than the > actual FE change. On the way, I improved the error message for > 'omp end <token> junk' and 'omp cancellation <junk>'. > And I encountered one issue with the reductions and the 'task' modifier, > https://gcc.gnu.org/PR101948
Commented on the PR. > Otherwise, the patch is straight forward and, hence, a bit boring. > > Tobias > > PS: I noted that > if (.false.) & > !$omp cancellation do > gives an error in C/C++ FE but not in the Fortran FE. With .true. it > reaches the ME and does give a ME error about an orphaned construct. > I did not fill a PR – but if someone thinks it should print an error, > feel free to open a PR. This isn't just Fortran, e.g. C++ void foo (void) { if constexpr (0) { #pragma omp cancellation point parallel } } isn't reported either. That is the disadvantage of late diagnostics of issues, on the other side having to duplicate everything for all the FEs... And one can include there anything that is reported during gimplification, omp lowering (e.g. nesting of regions diagnostics there, ...) etc. Say default(none) parallel mentioning vars not being explicitly privatized if it appears in discarded stmts etc. Perhaps Fortran if (.false.) and C++ constexpr if is something we should discuss in the committee at some point. > gcc/fortran/ChangeLog: > > * dump-parse-tree.c (show_omp_node, show_code_node): Handle > EXEC_OMP_SCOPE. > * gfortran.h (enum gfc_statement): Add ST_OMP_(END_)SCOPE. > (enum gfc_exec_op): Add EXEC_OMP_SCOPE. > * match.h (gfc_match_omp_scope): New. > * openmp.c (OMP_SCOPE_CLAUSES): Define > (gfc_match_omp_scope): New. > (gfc_match_omp_cancellation_point, gfc_match_omp_end_nowait): > Improve error diagnostic. > (omp_code_to_statement): Handle ST_OMP_SCOPE. > (gfc_resolve_omp_directive): Handle EXEC_OMP_SCOPE. > * parse.c (decode_omp_directive, next_statement, > gfc_ascii_statement, parse_omp_structured_block, > parse_executable): Handle OpenMP's scope construct. > * resolve.c (gfc_resolve_blocks): Likewise > * st.c (gfc_free_statement): Likewise > * trans-openmp.c (gfc_trans_omp_scope): New. > (gfc_trans_omp_directive): Call it. > * trans.c (trans_code): handle EXEC_OMP_SCOPE. > > libgomp/ChangeLog: > > * testsuite/libgomp.fortran/scope-1.f90: New test. > * testsuite/libgomp.fortran/task-reduction-16.f90: New test. > > gcc/testsuite/ChangeLog: > > * gfortran.dg/gomp/scan-1.f90: > * gfortran.dg/gomp/cancel-1.f90: New test. > * gfortran.dg/gomp/cancel-4.f90: New test. > * gfortran.dg/gomp/loop-4.f90: New test. > * gfortran.dg/gomp/nesting-1.f90: New test. > * gfortran.dg/gomp/nesting-2.f90: New test. > * gfortran.dg/gomp/nesting-3.f90: New test. > * gfortran.dg/gomp/nowait-1.f90: New test. > * gfortran.dg/gomp/reduction-task-1.f90: New test. > * gfortran.dg/gomp/reduction-task-2.f90: New test. > * gfortran.dg/gomp/reduction-task-2a.f90: New test. > * gfortran.dg/gomp/reduction-task-3.f90: New test. > * gfortran.dg/gomp/scope-1.f90: New test. > * gfortran.dg/gomp/scope-2.f90: New test. LGTM, thanks. Jakub