From 4078afc6d23e25df6baedad61b224ef86a94d42f Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Fri, 12 Apr 2024 14:52:24 -0500 Subject: [PATCH] [LLVM][OpenMP] Add "nowait" clause as valid for "workshare" (#88426) Add the "nowait" clause to the list of allowed clauses for the "workshare" directive. This will make it consistent with other directives (which are shared between C/C++ and Fortran). The parser will still reject "nowait" on "!$omp workshare", so this has no effect on accepting/rejecting Fortran source code. --- flang/lib/Semantics/check-omp-structure.h | 1 + flang/test/Semantics/OpenMP/clause-validity01.f90 | 3 +++ llvm/include/llvm/Frontend/OpenMP/OMP.td | 3 +++ 3 files changed, 7 insertions(+) diff --git a/flang/lib/Semantics/check-omp-structure.h b/flang/lib/Semantics/check-omp-structure.h index 33243d926cf1..8287653458e1 100644 --- a/flang/lib/Semantics/check-omp-structure.h +++ b/flang/lib/Semantics/check-omp-structure.h @@ -42,6 +42,7 @@ static const OmpDirectiveSet noWaitClauseNotAllowedSet{ Directive::OMPD_do_simd, Directive::OMPD_sections, Directive::OMPD_single, + Directive::OMPD_workshare, }; } // namespace omp } // namespace llvm diff --git a/flang/test/Semantics/OpenMP/clause-validity01.f90 b/flang/test/Semantics/OpenMP/clause-validity01.f90 index 977a52986461..74f154bb0ad6 100644 --- a/flang/test/Semantics/OpenMP/clause-validity01.f90 +++ b/flang/test/Semantics/OpenMP/clause-validity01.f90 @@ -342,6 +342,9 @@ a = 1.0 !ERROR: COPYPRIVATE clause is not allowed on the END WORKSHARE directive !$omp end workshare nowait copyprivate(a) + !$omp workshare nowait + !ERROR: NOWAIT clause is not allowed on the WORKSHARE directive, use it on OMP END WORKSHARE directive + !$omp end workshare !$omp end parallel ! 2.8.1 simd-clause -> safelen-clause | diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td index d9a931438b42..e91169e8da1a 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMP.td +++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td @@ -2115,6 +2115,9 @@ def OMP_scope : Directive<"scope"> { let association = AS_Block; } def OMP_Workshare : Directive<"workshare"> { + let allowedOnceClauses = [ + VersionedClause + ]; let association = AS_Block; } def OMP_ParallelWorkshare : Directive<"parallel workshare"> {