[flang-commits] [flang] 2894d75 - [Flang][OpenMP] Allow workdistribute inside 'target teams' (#199006)
via flang-commits
flang-commits at lists.llvm.org
Mon May 25 06:57:28 PDT 2026
Author: Sergio Afonso
Date: 2026-05-25T14:57:24+01:00
New Revision: 2894d7502f0b9ee8a3fc26867f180838c3aca3a1
URL: https://github.com/llvm/llvm-project/commit/2894d7502f0b9ee8a3fc26867f180838c3aca3a1
DIFF: https://github.com/llvm/llvm-project/commit/2894d7502f0b9ee8a3fc26867f180838c3aca3a1.diff
LOG: [Flang][OpenMP] Allow workdistribute inside 'target teams' (#199006)
Currently, a `workdistribute` construct nested inside of a combined
`target teams` is incorrectly reported as an error. This patch fixes
that.
Added:
flang/test/Semantics/OpenMP/workdistribute05.f90
Modified:
flang/lib/Semantics/check-omp-structure.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 512de68d63e7e..2e6c0720c77ea 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -1138,7 +1138,7 @@ void OmpStructureChecker::Enter(const parser::OmpBlockConstruct &x) {
"directives outside of the TEAMS construct"_err_en_US);
}
if (GetContext().directive == llvm::omp::Directive::OMPD_workdistribute &&
- GetContextParent().directive != llvm::omp::Directive::OMPD_teams) {
+ !llvm::omp::bottomTeamsSet.test(GetContextParent().directive)) {
context_.Say(x.BeginDir().DirName().source,
"%s region can only be strictly nested within TEAMS region"_err_en_US,
ContextDirectiveAsFortran());
diff --git a/flang/test/Semantics/OpenMP/workdistribute05.f90 b/flang/test/Semantics/OpenMP/workdistribute05.f90
new file mode 100644
index 0000000000000..3c06bf4f1a4c9
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/workdistribute05.f90
@@ -0,0 +1,23 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=60
+! OpenMP Version 6.0
+! workdistribute Construct
+! Make sure that standalone workdistribute doesn't trigger errors when used in
+! supported contexts.
+
+subroutine teams_workdistribute()
+ integer :: a
+ !$omp teams
+ !$omp workdistribute
+ a = 1
+ !$omp end workdistribute
+ !$omp end teams
+end subroutine teams_workdistribute
+
+subroutine target_teams_workdistribute()
+ integer :: a
+ !$omp target teams
+ !$omp workdistribute
+ a = 1
+ !$omp end workdistribute
+ !$omp end target teams
+end subroutine target_teams_workdistribute
More information about the flang-commits
mailing list