Skip to content

Conversation

@anchuraj
Copy link
Contributor

Enables parsing support for threadset clause in OpenMP. Initial support was added in #135807

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir flang:openmp flang:semantics flang:parser labels Nov 27, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 27, 2025

@llvm/pr-subscribers-flang-semantics

@llvm/pr-subscribers-flang-fir-hlfir

Author: Anchu Rajendran S (anchuraj)

Changes

Enables parsing support for threadset clause in OpenMP. Initial support was added in #135807


Full diff: https://github.com/llvm/llvm-project/pull/169856.diff

5 Files Affected:

  • (modified) flang/lib/Parser/openmp-parsers.cpp (+7-1)
  • (modified) flang/lib/Parser/unparse.cpp (+1)
  • (added) flang/test/Lower/OpenMP/Todo/threadset.f90 (+10)
  • (added) flang/test/Parser/OpenMP/threadset-clause.f90 (+79)
  • (added) flang/test/Semantics/OpenMP/threadset-clause.f90 (+9)
diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp
index e2da60ed19de8..45abcc13be267 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -1168,6 +1168,10 @@ TYPE_PARSER(construct<OmpTaskReductionClause>(
 
 TYPE_PARSER(construct<OmpTransparentClause>(scalarIntExpr))
 
+TYPE_PARSER(construct<OmpThreadsetClause>(
+    "omp_pool" >> pure(OmpThreadsetClause::ThreadsetPolicy::Omp_Pool) ||
+    "omp_team" >> pure(OmpThreadsetClause::ThreadsetPolicy::Omp_Team)))
+
 // OMP 5.0 2.11.4 allocate-clause -> ALLOCATE ([allocator:] variable-name-list)
 // OMP 5.2 2.13.4 allocate-clause -> ALLOCATE ([allocate-modifier
 //                                   [, allocate-modifier] :]
@@ -1519,7 +1523,9 @@ TYPE_PARSER( //
                    parenthesized(nonemptyList(scalarIntExpr)))) ||
     "PERMUTATION" >> construct<OmpClause>(construct<OmpClause::Permutation>(
                          parenthesized(nonemptyList(scalarIntExpr)))) ||
-    "THREADS" >> construct<OmpClause>(construct<OmpClause::Threads>()) ||
+    "THREADS"_id >> construct<OmpClause>(construct<OmpClause::Threads>()) ||
+    "THREADSET" >> construct<OmpClause>(construct<OmpClause::Threadset>(
+                       parenthesized(Parser<OmpThreadsetClause>{}))) ||
     "THREAD_LIMIT" >> construct<OmpClause>(construct<OmpClause::ThreadLimit>(
                           parenthesized(scalarIntExpr))) ||
     "TO" >> construct<OmpClause>(construct<OmpClause::To>(
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index f81200d092b11..2a6d389e8ecf9 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -2789,6 +2789,7 @@ class UnparseVisitor {
   WALK_NESTED_ENUM(OmpTaskDependenceType, Value) // OMP task-dependence-type
   WALK_NESTED_ENUM(OmpScheduleClause, Kind) // OMP schedule-kind
   WALK_NESTED_ENUM(OmpSeverityClause, Severity) // OMP severity
+  WALK_NESTED_ENUM(OmpThreadsetClause, ThreadsetPolicy) // OMP threadset
   WALK_NESTED_ENUM(OmpAccessGroup, Value)
   WALK_NESTED_ENUM(OmpDeviceModifier, Value) // OMP device modifier
   WALK_NESTED_ENUM(
diff --git a/flang/test/Lower/OpenMP/Todo/threadset.f90 b/flang/test/Lower/OpenMP/Todo/threadset.f90
new file mode 100644
index 0000000000000..b022baf02654b
--- /dev/null
+++ b/flang/test/Lower/OpenMP/Todo/threadset.f90
@@ -0,0 +1,10 @@
+! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=60 -o - %s 2>&1 | FileCheck %s
+
+! CHECK: not yet implemented: THREADSET clause is not implemented yet
+
+subroutine f00(x)
+  integer :: x(10)
+  !$omp task threadset(omp_pool)
+  x = x + 1
+  !$omp end task
+end
diff --git a/flang/test/Parser/OpenMP/threadset-clause.f90 b/flang/test/Parser/OpenMP/threadset-clause.f90
new file mode 100644
index 0000000000000..dfd27aace1ed1
--- /dev/null
+++ b/flang/test/Parser/OpenMP/threadset-clause.f90
@@ -0,0 +1,79 @@
+!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=60 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s
+!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=60 %s | FileCheck --check-prefix="PARSE-TREE" %s
+
+subroutine f00(x)
+  integer :: x(10)
+!$omp task threadset(omp_pool)
+  x = x + 1
+!$omp end task
+end
+
+!UNPARSE: SUBROUTINE f00 (x)
+!UNPARSE:  INTEGER x(10_4)
+!UNPARSE: !$OMP TASK THREADSET(OMP_POOL)
+!UNPARSE:   x=x+1_4
+!UNPARSE: !$OMP END TASK
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: OmpBeginDirective
+!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = task
+!PARSE-TREE: | OmpClauseList -> OmpClause -> Threadset -> OmpThreadsetClause -> ThreadsetPolicy = Omp_Pool
+
+subroutine f001(x)
+  integer :: x(10)
+!$omp task threadset(omp_team)
+  x = x + 1
+!$omp end task
+end
+
+!UNPARSE: SUBROUTINE f001 (x)
+!UNPARSE:  INTEGER x(10_4)
+!UNPARSE: !$OMP TASK THREADSET(OMP_TEAM)
+!UNPARSE:   x=x+1_4
+!UNPARSE: !$OMP END TASK
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: OmpBeginDirective
+!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = task
+!PARSE-TREE: | OmpClauseList -> OmpClause -> Threadset -> OmpThreadsetClause -> ThreadsetPolicy = Omp_Team
+
+
+subroutine f002(x)
+  integer :: i
+!$omp taskloop threadset(omp_team)
+  do i = 1, 10
+  end do
+!$omp end taskloop
+end
+
+!UNPARSE: SUBROUTINE f002 (x)
+!UNPARSE:  INTEGER i
+!UNPARSE: !$OMP TASKLOOP THREADSET(OMP_TEAM)
+!UNPARSE:    DO i=1_4,10_4
+!UNPARSE:    END DO
+!UNPARSE: !$OMP END TASK
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: OmpBeginLoopDirective
+!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = taskloop
+!PARSE-TREE: | OmpClauseList -> OmpClause -> Threadset -> OmpThreadsetClause -> ThreadsetPolicy = Omp_Team
+
+subroutine f003(x)
+  integer :: i
+!$omp taskloop threadset(omp_team)
+  do i = 1, 10
+  end do
+!$omp end taskloop
+end
+
+!UNPARSE: SUBROUTINE f003 (x)
+!UNPARSE:  INTEGER i
+!UNPARSE: !$OMP TASKLOOP THREADSET(OMP_POOL)
+!UNPARSE:    DO i=1_4,10_4
+!UNPARSE:    END DO
+!UNPARSE: !$OMP END TASK
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: OmpBeginLoopDirective
+!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = taskloop
+!PARSE-TREE: | OmpClauseList -> OmpClause -> Threadset -> OmpThreadsetClause -> ThreadsetPolicy = Omp_Pool
diff --git a/flang/test/Semantics/OpenMP/threadset-clause.f90 b/flang/test/Semantics/OpenMP/threadset-clause.f90
new file mode 100644
index 0000000000000..59cd3ef503bd9
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/threadset-clause.f90
@@ -0,0 +1,9 @@
+!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=45
+
+subroutine f00(x)
+  integer :: x(10)
+!ERROR: THREADSET clause is not allowed on directive TASK in OpenMP v4.5, try -fopenmp-version=60
+!$omp task threadset(omp_pool)
+  x = x + 1
+!$omp end task
+end

@llvmbot
Copy link
Member

llvmbot commented Nov 27, 2025

@llvm/pr-subscribers-flang-openmp

Author: Anchu Rajendran S (anchuraj)

Changes

Enables parsing support for threadset clause in OpenMP. Initial support was added in #135807


Full diff: https://github.com/llvm/llvm-project/pull/169856.diff

5 Files Affected:

  • (modified) flang/lib/Parser/openmp-parsers.cpp (+7-1)
  • (modified) flang/lib/Parser/unparse.cpp (+1)
  • (added) flang/test/Lower/OpenMP/Todo/threadset.f90 (+10)
  • (added) flang/test/Parser/OpenMP/threadset-clause.f90 (+79)
  • (added) flang/test/Semantics/OpenMP/threadset-clause.f90 (+9)
diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp
index e2da60ed19de8..45abcc13be267 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -1168,6 +1168,10 @@ TYPE_PARSER(construct<OmpTaskReductionClause>(
 
 TYPE_PARSER(construct<OmpTransparentClause>(scalarIntExpr))
 
+TYPE_PARSER(construct<OmpThreadsetClause>(
+    "omp_pool" >> pure(OmpThreadsetClause::ThreadsetPolicy::Omp_Pool) ||
+    "omp_team" >> pure(OmpThreadsetClause::ThreadsetPolicy::Omp_Team)))
+
 // OMP 5.0 2.11.4 allocate-clause -> ALLOCATE ([allocator:] variable-name-list)
 // OMP 5.2 2.13.4 allocate-clause -> ALLOCATE ([allocate-modifier
 //                                   [, allocate-modifier] :]
@@ -1519,7 +1523,9 @@ TYPE_PARSER( //
                    parenthesized(nonemptyList(scalarIntExpr)))) ||
     "PERMUTATION" >> construct<OmpClause>(construct<OmpClause::Permutation>(
                          parenthesized(nonemptyList(scalarIntExpr)))) ||
-    "THREADS" >> construct<OmpClause>(construct<OmpClause::Threads>()) ||
+    "THREADS"_id >> construct<OmpClause>(construct<OmpClause::Threads>()) ||
+    "THREADSET" >> construct<OmpClause>(construct<OmpClause::Threadset>(
+                       parenthesized(Parser<OmpThreadsetClause>{}))) ||
     "THREAD_LIMIT" >> construct<OmpClause>(construct<OmpClause::ThreadLimit>(
                           parenthesized(scalarIntExpr))) ||
     "TO" >> construct<OmpClause>(construct<OmpClause::To>(
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index f81200d092b11..2a6d389e8ecf9 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -2789,6 +2789,7 @@ class UnparseVisitor {
   WALK_NESTED_ENUM(OmpTaskDependenceType, Value) // OMP task-dependence-type
   WALK_NESTED_ENUM(OmpScheduleClause, Kind) // OMP schedule-kind
   WALK_NESTED_ENUM(OmpSeverityClause, Severity) // OMP severity
+  WALK_NESTED_ENUM(OmpThreadsetClause, ThreadsetPolicy) // OMP threadset
   WALK_NESTED_ENUM(OmpAccessGroup, Value)
   WALK_NESTED_ENUM(OmpDeviceModifier, Value) // OMP device modifier
   WALK_NESTED_ENUM(
diff --git a/flang/test/Lower/OpenMP/Todo/threadset.f90 b/flang/test/Lower/OpenMP/Todo/threadset.f90
new file mode 100644
index 0000000000000..b022baf02654b
--- /dev/null
+++ b/flang/test/Lower/OpenMP/Todo/threadset.f90
@@ -0,0 +1,10 @@
+! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=60 -o - %s 2>&1 | FileCheck %s
+
+! CHECK: not yet implemented: THREADSET clause is not implemented yet
+
+subroutine f00(x)
+  integer :: x(10)
+  !$omp task threadset(omp_pool)
+  x = x + 1
+  !$omp end task
+end
diff --git a/flang/test/Parser/OpenMP/threadset-clause.f90 b/flang/test/Parser/OpenMP/threadset-clause.f90
new file mode 100644
index 0000000000000..dfd27aace1ed1
--- /dev/null
+++ b/flang/test/Parser/OpenMP/threadset-clause.f90
@@ -0,0 +1,79 @@
+!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=60 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s
+!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=60 %s | FileCheck --check-prefix="PARSE-TREE" %s
+
+subroutine f00(x)
+  integer :: x(10)
+!$omp task threadset(omp_pool)
+  x = x + 1
+!$omp end task
+end
+
+!UNPARSE: SUBROUTINE f00 (x)
+!UNPARSE:  INTEGER x(10_4)
+!UNPARSE: !$OMP TASK THREADSET(OMP_POOL)
+!UNPARSE:   x=x+1_4
+!UNPARSE: !$OMP END TASK
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: OmpBeginDirective
+!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = task
+!PARSE-TREE: | OmpClauseList -> OmpClause -> Threadset -> OmpThreadsetClause -> ThreadsetPolicy = Omp_Pool
+
+subroutine f001(x)
+  integer :: x(10)
+!$omp task threadset(omp_team)
+  x = x + 1
+!$omp end task
+end
+
+!UNPARSE: SUBROUTINE f001 (x)
+!UNPARSE:  INTEGER x(10_4)
+!UNPARSE: !$OMP TASK THREADSET(OMP_TEAM)
+!UNPARSE:   x=x+1_4
+!UNPARSE: !$OMP END TASK
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: OmpBeginDirective
+!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = task
+!PARSE-TREE: | OmpClauseList -> OmpClause -> Threadset -> OmpThreadsetClause -> ThreadsetPolicy = Omp_Team
+
+
+subroutine f002(x)
+  integer :: i
+!$omp taskloop threadset(omp_team)
+  do i = 1, 10
+  end do
+!$omp end taskloop
+end
+
+!UNPARSE: SUBROUTINE f002 (x)
+!UNPARSE:  INTEGER i
+!UNPARSE: !$OMP TASKLOOP THREADSET(OMP_TEAM)
+!UNPARSE:    DO i=1_4,10_4
+!UNPARSE:    END DO
+!UNPARSE: !$OMP END TASK
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: OmpBeginLoopDirective
+!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = taskloop
+!PARSE-TREE: | OmpClauseList -> OmpClause -> Threadset -> OmpThreadsetClause -> ThreadsetPolicy = Omp_Team
+
+subroutine f003(x)
+  integer :: i
+!$omp taskloop threadset(omp_team)
+  do i = 1, 10
+  end do
+!$omp end taskloop
+end
+
+!UNPARSE: SUBROUTINE f003 (x)
+!UNPARSE:  INTEGER i
+!UNPARSE: !$OMP TASKLOOP THREADSET(OMP_POOL)
+!UNPARSE:    DO i=1_4,10_4
+!UNPARSE:    END DO
+!UNPARSE: !$OMP END TASK
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: OmpBeginLoopDirective
+!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = taskloop
+!PARSE-TREE: | OmpClauseList -> OmpClause -> Threadset -> OmpThreadsetClause -> ThreadsetPolicy = Omp_Pool
diff --git a/flang/test/Semantics/OpenMP/threadset-clause.f90 b/flang/test/Semantics/OpenMP/threadset-clause.f90
new file mode 100644
index 0000000000000..59cd3ef503bd9
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/threadset-clause.f90
@@ -0,0 +1,9 @@
+!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=45
+
+subroutine f00(x)
+  integer :: x(10)
+!ERROR: THREADSET clause is not allowed on directive TASK in OpenMP v4.5, try -fopenmp-version=60
+!$omp task threadset(omp_pool)
+  x = x + 1
+!$omp end task
+end

@llvmbot
Copy link
Member

llvmbot commented Nov 27, 2025

@llvm/pr-subscribers-flang-parser

Author: Anchu Rajendran S (anchuraj)

Changes

Enables parsing support for threadset clause in OpenMP. Initial support was added in #135807


Full diff: https://github.com/llvm/llvm-project/pull/169856.diff

5 Files Affected:

  • (modified) flang/lib/Parser/openmp-parsers.cpp (+7-1)
  • (modified) flang/lib/Parser/unparse.cpp (+1)
  • (added) flang/test/Lower/OpenMP/Todo/threadset.f90 (+10)
  • (added) flang/test/Parser/OpenMP/threadset-clause.f90 (+79)
  • (added) flang/test/Semantics/OpenMP/threadset-clause.f90 (+9)
diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp
index e2da60ed19de8..45abcc13be267 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -1168,6 +1168,10 @@ TYPE_PARSER(construct<OmpTaskReductionClause>(
 
 TYPE_PARSER(construct<OmpTransparentClause>(scalarIntExpr))
 
+TYPE_PARSER(construct<OmpThreadsetClause>(
+    "omp_pool" >> pure(OmpThreadsetClause::ThreadsetPolicy::Omp_Pool) ||
+    "omp_team" >> pure(OmpThreadsetClause::ThreadsetPolicy::Omp_Team)))
+
 // OMP 5.0 2.11.4 allocate-clause -> ALLOCATE ([allocator:] variable-name-list)
 // OMP 5.2 2.13.4 allocate-clause -> ALLOCATE ([allocate-modifier
 //                                   [, allocate-modifier] :]
@@ -1519,7 +1523,9 @@ TYPE_PARSER( //
                    parenthesized(nonemptyList(scalarIntExpr)))) ||
     "PERMUTATION" >> construct<OmpClause>(construct<OmpClause::Permutation>(
                          parenthesized(nonemptyList(scalarIntExpr)))) ||
-    "THREADS" >> construct<OmpClause>(construct<OmpClause::Threads>()) ||
+    "THREADS"_id >> construct<OmpClause>(construct<OmpClause::Threads>()) ||
+    "THREADSET" >> construct<OmpClause>(construct<OmpClause::Threadset>(
+                       parenthesized(Parser<OmpThreadsetClause>{}))) ||
     "THREAD_LIMIT" >> construct<OmpClause>(construct<OmpClause::ThreadLimit>(
                           parenthesized(scalarIntExpr))) ||
     "TO" >> construct<OmpClause>(construct<OmpClause::To>(
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index f81200d092b11..2a6d389e8ecf9 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -2789,6 +2789,7 @@ class UnparseVisitor {
   WALK_NESTED_ENUM(OmpTaskDependenceType, Value) // OMP task-dependence-type
   WALK_NESTED_ENUM(OmpScheduleClause, Kind) // OMP schedule-kind
   WALK_NESTED_ENUM(OmpSeverityClause, Severity) // OMP severity
+  WALK_NESTED_ENUM(OmpThreadsetClause, ThreadsetPolicy) // OMP threadset
   WALK_NESTED_ENUM(OmpAccessGroup, Value)
   WALK_NESTED_ENUM(OmpDeviceModifier, Value) // OMP device modifier
   WALK_NESTED_ENUM(
diff --git a/flang/test/Lower/OpenMP/Todo/threadset.f90 b/flang/test/Lower/OpenMP/Todo/threadset.f90
new file mode 100644
index 0000000000000..b022baf02654b
--- /dev/null
+++ b/flang/test/Lower/OpenMP/Todo/threadset.f90
@@ -0,0 +1,10 @@
+! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=60 -o - %s 2>&1 | FileCheck %s
+
+! CHECK: not yet implemented: THREADSET clause is not implemented yet
+
+subroutine f00(x)
+  integer :: x(10)
+  !$omp task threadset(omp_pool)
+  x = x + 1
+  !$omp end task
+end
diff --git a/flang/test/Parser/OpenMP/threadset-clause.f90 b/flang/test/Parser/OpenMP/threadset-clause.f90
new file mode 100644
index 0000000000000..dfd27aace1ed1
--- /dev/null
+++ b/flang/test/Parser/OpenMP/threadset-clause.f90
@@ -0,0 +1,79 @@
+!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=60 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s
+!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=60 %s | FileCheck --check-prefix="PARSE-TREE" %s
+
+subroutine f00(x)
+  integer :: x(10)
+!$omp task threadset(omp_pool)
+  x = x + 1
+!$omp end task
+end
+
+!UNPARSE: SUBROUTINE f00 (x)
+!UNPARSE:  INTEGER x(10_4)
+!UNPARSE: !$OMP TASK THREADSET(OMP_POOL)
+!UNPARSE:   x=x+1_4
+!UNPARSE: !$OMP END TASK
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: OmpBeginDirective
+!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = task
+!PARSE-TREE: | OmpClauseList -> OmpClause -> Threadset -> OmpThreadsetClause -> ThreadsetPolicy = Omp_Pool
+
+subroutine f001(x)
+  integer :: x(10)
+!$omp task threadset(omp_team)
+  x = x + 1
+!$omp end task
+end
+
+!UNPARSE: SUBROUTINE f001 (x)
+!UNPARSE:  INTEGER x(10_4)
+!UNPARSE: !$OMP TASK THREADSET(OMP_TEAM)
+!UNPARSE:   x=x+1_4
+!UNPARSE: !$OMP END TASK
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: OmpBeginDirective
+!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = task
+!PARSE-TREE: | OmpClauseList -> OmpClause -> Threadset -> OmpThreadsetClause -> ThreadsetPolicy = Omp_Team
+
+
+subroutine f002(x)
+  integer :: i
+!$omp taskloop threadset(omp_team)
+  do i = 1, 10
+  end do
+!$omp end taskloop
+end
+
+!UNPARSE: SUBROUTINE f002 (x)
+!UNPARSE:  INTEGER i
+!UNPARSE: !$OMP TASKLOOP THREADSET(OMP_TEAM)
+!UNPARSE:    DO i=1_4,10_4
+!UNPARSE:    END DO
+!UNPARSE: !$OMP END TASK
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: OmpBeginLoopDirective
+!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = taskloop
+!PARSE-TREE: | OmpClauseList -> OmpClause -> Threadset -> OmpThreadsetClause -> ThreadsetPolicy = Omp_Team
+
+subroutine f003(x)
+  integer :: i
+!$omp taskloop threadset(omp_team)
+  do i = 1, 10
+  end do
+!$omp end taskloop
+end
+
+!UNPARSE: SUBROUTINE f003 (x)
+!UNPARSE:  INTEGER i
+!UNPARSE: !$OMP TASKLOOP THREADSET(OMP_POOL)
+!UNPARSE:    DO i=1_4,10_4
+!UNPARSE:    END DO
+!UNPARSE: !$OMP END TASK
+!UNPARSE: END SUBROUTINE
+
+!PARSE-TREE: OmpBeginLoopDirective
+!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = taskloop
+!PARSE-TREE: | OmpClauseList -> OmpClause -> Threadset -> OmpThreadsetClause -> ThreadsetPolicy = Omp_Pool
diff --git a/flang/test/Semantics/OpenMP/threadset-clause.f90 b/flang/test/Semantics/OpenMP/threadset-clause.f90
new file mode 100644
index 0000000000000..59cd3ef503bd9
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/threadset-clause.f90
@@ -0,0 +1,9 @@
+!RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=45
+
+subroutine f00(x)
+  integer :: x(10)
+!ERROR: THREADSET clause is not allowed on directive TASK in OpenMP v4.5, try -fopenmp-version=60
+!$omp task threadset(omp_pool)
+  x = x + 1
+!$omp end task
+end

@github-actions
Copy link

github-actions bot commented Nov 27, 2025

🐧 Linux x64 Test Results

  • 4088 tests passed
  • 202 tests skipped

Copy link
Contributor

@kparzysz kparzysz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Comment on lines 1172 to 1173
"omp_pool" >> pure(OmpThreadsetClause::ThreadsetPolicy::Omp_Pool) ||
"omp_team" >> pure(OmpThreadsetClause::ThreadsetPolicy::Omp_Team)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention is to spell the source names in all capitals, e.g. OMP_POOL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Thank you for reviewing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants