[flang-commits] [flang] [Flang][OpenMP] Fix nested PARALLEL SECTIONS validation (PR #179419)

via flang-commits flang-commits at lists.llvm.org
Tue Feb 3 06:13:58 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- flang/lib/Semantics/check-omp-loop.cpp flang/lib/Semantics/check-omp-structure.cpp flang/lib/Semantics/check-omp-structure.h --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/flang/lib/Semantics/check-omp-loop.cpp b/flang/lib/Semantics/check-omp-loop.cpp
index 2ba1432af..5f6bbd909 100644
--- a/flang/lib/Semantics/check-omp-loop.cpp
+++ b/flang/lib/Semantics/check-omp-loop.cpp
@@ -460,7 +460,7 @@ void OmpStructureChecker::Enter(const parser::OpenMPLoopConstruct &x) {
 
     // nesting check
     HasInvalidWorksharingNesting(
-        beginName.source, llvm::omp::nestedWorkshareErrSet,beginName.v);
+        beginName.source, llvm::omp::nestedWorkshareErrSet, beginName.v);
   }
   SetLoopInfo(x);
 
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 0c71ab1e4..d3cf7b555 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -638,25 +638,26 @@ bool OmpStructureChecker::IsCombinedParallelWorksharing(
   // Combined parallel-worksharing constructs create their own parallel region
   // They should not be subject to worksharing nesting restrictions
   switch (directive) {
-    case llvm::omp::OMPD_parallel_for:
-      return true;
-    case llvm::omp::OMPD_parallel_for_simd:
-      return true;
-    case llvm::omp::OMPD_parallel_sections:
-      return true;
-    case llvm::omp::OMPD_parallel_workshare:
-      return true;
-    default:
-      return false;
+  case llvm::omp::OMPD_parallel_for:
+    return true;
+  case llvm::omp::OMPD_parallel_for_simd:
+    return true;
+  case llvm::omp::OMPD_parallel_sections:
+    return true;
+  case llvm::omp::OMPD_parallel_workshare:
+    return true;
+  default:
+    return false;
   }
 }
 
 bool OmpStructureChecker::HasInvalidWorksharingNesting(
-    const parser::CharBlock &source, const OmpDirectiveSet &set,llvm::omp::Directive directive) {
+    const parser::CharBlock &source, const OmpDirectiveSet &set,
+    llvm::omp::Directive directive) {
   // set contains all the invalid closely nested directives
   // for the given directive (`source` here)
   if (IsCombinedParallelWorksharing(directive)) {
-    return false;  
+    return false;
   }
   if (IsCloselyNestedRegion(set)) {
     context_.Say(source,
@@ -1076,7 +1077,7 @@ void OmpStructureChecker::Enter(const parser::OmpBlockConstruct &x) {
   case llvm::omp::OMPD_parallel_workshare:
     CheckWorkshareBlockStmts(block, beginSpec.source);
     HasInvalidWorksharingNesting(
-        beginSpec.source, llvm::omp::nestedWorkshareErrSet,beginSpec.DirId());
+        beginSpec.source, llvm::omp::nestedWorkshareErrSet, beginSpec.DirId());
     break;
   case llvm::omp::OMPD_workdistribute:
     if (!CurrentDirectiveIsNested()) {
@@ -1094,7 +1095,7 @@ void OmpStructureChecker::Enter(const parser::OmpBlockConstruct &x) {
     // TODO: This check needs to be extended while implementing nesting of
     // regions checks.
     HasInvalidWorksharingNesting(
-        beginSpec.source, llvm::omp::nestedWorkshareErrSet,beginSpec.DirId());
+        beginSpec.source, llvm::omp::nestedWorkshareErrSet, beginSpec.DirId());
     break;
   case llvm::omp::Directive::OMPD_task:
     for (const auto &clause : beginSpec.Clauses().v) {
@@ -1253,8 +1254,8 @@ void OmpStructureChecker::Enter(const parser::OpenMPSectionsConstruct &x) {
     CheckNoBranching(
         std::get<parser::Block>(section.t), beginName.v, beginName.source);
   }
-    HasInvalidWorksharingNesting(
-        beginName.source, llvm::omp::nestedWorkshareErrSet,beginSpec.DirId());
+  HasInvalidWorksharingNesting(
+      beginName.source, llvm::omp::nestedWorkshareErrSet, beginSpec.DirId());
 }
 
 void OmpStructureChecker::Leave(const parser::OpenMPSectionsConstruct &) {
diff --git a/flang/lib/Semantics/check-omp-structure.h b/flang/lib/Semantics/check-omp-structure.h
index 8afbfd6a6..b155ef3fc 100644
--- a/flang/lib/Semantics/check-omp-structure.h
+++ b/flang/lib/Semantics/check-omp-structure.h
@@ -192,9 +192,8 @@ private:
   void CheckMultListItems();
   void CheckStructureComponent(
       const parser::OmpObjectList &objects, llvm::omp::Clause clauseId);
-   bool HasInvalidWorksharingNesting(
-      const parser::CharBlock &, const OmpDirectiveSet &,
-      llvm::omp::Directive directive);
+  bool HasInvalidWorksharingNesting(const parser::CharBlock &,
+      const OmpDirectiveSet &, llvm::omp::Directive directive);
   bool IsCloselyNestedRegion(const OmpDirectiveSet &set);
   bool IsNestedInDirective(llvm::omp::Directive directive);
   bool IsCombinedParallelWorksharing(llvm::omp::Directive directive) const;

``````````

</details>


https://github.com/llvm/llvm-project/pull/179419


More information about the flang-commits mailing list