[flang-commits] [flang] [llvm] [Flang][OpenMP] Support certain directives in PURE procedures (PR #212676)

via flang-commits flang-commits at lists.llvm.org
Thu Aug 6 23:08:13 PDT 2026


================
@@ -945,6 +945,33 @@ void OmpStructureChecker::CheckDirectiveDeprecation(
   // one another, but only the top-level directive should cause a warning.
 }
 
+void OmpStructureChecker::CheckDirectiveInPureProcedure(
+    parser::CharBlock source, llvm::omp::Directive id) {
+  const Scope &scope{context_.FindScope(source)};
+  if (!FindPureProcedureContaining(scope)) {
+    return;
+  }
+  unsigned version{context_.langOptions().OpenMPVersion};
----------------
ShashwathiNavada wrote:

Thanks for the review!

1. You're right about `scan`. I missed that it is marked as having the **pure** property in OpenMP 6.0. Sorry about that.

2. Regarding `ordered simd`, `ordered` itself is not marked as having the **pure** property. Since `ordered simd` is still an `ordered` directive, I don't think it is currently permitted in a PURE procedure, so I haven't marked it as pure.

3. The previous boolean-based approach made it difficult to add version guards for directives that gained the **pure** property in later OpenMP versions. To address that, I've changed it to store the version since which a directive is pure. 

Please do let me know if you have a better suggestion, I'd be happy to update it.

Thank you!


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


More information about the flang-commits mailing list