[flang-commits] [flang] [flang][OpenMP] Centralize pushing/popping directive context (PR #204924)

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Mon Jun 22 05:52:49 PDT 2026


================
@@ -1041,22 +1041,21 @@ void OmpStructureChecker::Enter(const parser::OpenMPConstruct &x) {
         return CheckDirectiveSpelling(source, id);
       });
   parser::Walk(x, visitor);
-  if (GetOmpDirectiveName(x).v != llvm::omp::Directive::OMPD_section) {
-    dirStack_.push_back(&GetOmpDirectiveSpecification(x));
-  }
-
-  CheckDirectiveDeprecation(x);
 
-  if (GetOmpDirectiveName(x).v != llvm::omp::Directive::OMPD_section) {
-    dirStack_.push_back(&GetOmpDirectiveSpecification(x));
+  parser::OmpDirectiveName dirName{GetOmpDirectiveName(x)};
+  if (dirName.v == llvm::omp::Directive::OMPD_section) {
+    return;
   }
+  PushContextAndClauseSets(dirName.source, dirName.v);
+  dirStack_.push_back(&GetOmpDirectiveSpecification(x));
+  CheckDirectiveDeprecation(x);
 
   // Simd Construct with Ordered Construct Nesting check
   // We cannot use CurrentDirectiveIsNested() here because
   // PushContextAndClauseSets() has not been called yet, it is
   // called individually for each construct.  Therefore a
   // dirContext_ size `1` means the current construct is nested
----------------
kparzysz wrote:

Done.

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


More information about the flang-commits mailing list