[flang-commits] [flang] 97a105f - [Flang][OpenMP] Allow `parallel loop` inside of `teams` (#210679)
via flang-commits
flang-commits at lists.llvm.org
Mon Jul 20 07:01:49 PDT 2026
Author: Sergio Afonso
Date: 2026-07-20T15:01:43+01:00
New Revision: 97a105f8e681e8e9e5778b6f8bf95a8c365a05f6
URL: https://github.com/llvm/llvm-project/commit/97a105f8e681e8e9e5778b6f8bf95a8c365a05f6
DIFF: https://github.com/llvm/llvm-project/commit/97a105f8e681e8e9e5778b6f8bf95a8c365a05f6.diff
LOG: [Flang][OpenMP] Allow `parallel loop` inside of `teams` (#210679)
A missing `parallel_loop` directive in the `nestedTeamsAllowedSet`
currently causes code like the following to report a semantics issue:
```f90
!$omp teams
!$omp parallel loop
do i=1, 10
end do
!$omp end teams
```
This patch makes sure to accept it, since `parallel` is an allowed
construct to be immediately nested inside of `teams`, even when combined
with another construct.
Added:
flang/test/Semantics/OpenMP/teams_loop.f90
Modified:
flang/include/flang/Semantics/openmp-directive-sets.h
Removed:
################################################################################
diff --git a/flang/include/flang/Semantics/openmp-directive-sets.h b/flang/include/flang/Semantics/openmp-directive-sets.h
index b99dd8fe07204..ab1eb36976380 100644
--- a/flang/include/flang/Semantics/openmp-directive-sets.h
+++ b/flang/include/flang/Semantics/openmp-directive-sets.h
@@ -402,6 +402,7 @@ static const OmpDirectiveSet nestedTeamsAllowedSet{
Directive::OMPD_parallel,
Directive::OMPD_parallel_do,
Directive::OMPD_parallel_do_simd,
+ Directive::OMPD_parallel_loop,
Directive::OMPD_parallel_master,
Directive::OMPD_parallel_master_taskloop,
Directive::OMPD_parallel_master_taskloop_simd,
diff --git a/flang/test/Semantics/OpenMP/teams_loop.f90 b/flang/test/Semantics/OpenMP/teams_loop.f90
new file mode 100644
index 0000000000000..1d95f438a9177
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/teams_loop.f90
@@ -0,0 +1,37 @@
+! RUN: %flang_fc1 -fopenmp -fsyntax-only %s
+
+! Test that various ways of nesting combined and standalone `loop` constructs
+! inside of `teams` are accepted.
+
+subroutine test()
+ implicit none
+ integer :: i
+
+ !$omp teams
+ !$omp parallel loop
+ do i=1, 10
+ call foo()
+ end do
+ !$omp end teams
+
+ !$omp target teams
+ !$omp parallel loop
+ do i=1, 10
+ call foo()
+ end do
+ !$omp end target teams
+
+ !$omp target teams
+ !$omp loop
+ do i=1, 10
+ call foo()
+ end do
+ !$omp end target teams
+
+ !$omp teams
+ !$omp loop
+ do i=1, 10
+ call foo()
+ end do
+ !$omp end teams
+end subroutine
More information about the flang-commits
mailing list