[flang-commits] [flang] [Flang][OpenMP] Allow `parallel loop` inside of `teams` (PR #210679)
via flang-commits
flang-commits at lists.llvm.org
Mon Jul 20 03:43:52 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-openmp
Author: Sergio Afonso (skatrak)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/210679.diff
2 Files Affected:
- (modified) flang/include/flang/Semantics/openmp-directive-sets.h (+1)
- (added) flang/test/Semantics/OpenMP/teams_loop.f90 (+37)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/210679
More information about the flang-commits
mailing list