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

via flang-commits flang-commits at lists.llvm.org
Thu Jul 30 06:33:43 PDT 2026


================
@@ -945,6 +945,22 @@ 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) {
+  // A directive that does not have the "pure" property is not permitted to
+  // appear in a Fortran PURE procedure, since it may introduce side effects.
+  if (llvm::omp::isDirectivePure(id)) {
+    return;
+  }
+  const Scope &scope{context_.FindScope(source)};
+  if (FindPureProcedureContaining(scope)) {
----------------
ShashwathiNavada wrote:

Thank you for pointing that out. 
OpenMP 5.1 permits only _SIMD_ and _declarative_ directives in a PURE procedure, while OpenMP 5.2 additionally allows _metadirective, assume(s), nothing, error, and loop transformation constructs_. I have added the version guard accordingly.

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


More information about the flang-commits mailing list