[flang-commits] [flang] [llvm] [Flang][OpenMP] Support certain directives in PURE procedures (PR #212676)
via flang-commits
flang-commits at lists.llvm.org
Sun Aug 9 21:34:06 PDT 2026
================
@@ -945,6 +945,36 @@ 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};
+ // OpenMP 5.1 permits only SIMD and declarative directives in a PURE
+ // procedure; OpenMP 5.2 additionally permits metadirective, assume(s),
+ // nothing, error, and the loop-transforming constructs).
+ bool alwaysAllowed{id == llvm::omp::Directive::OMPD_simd ||
+ llvm::omp::getDirectiveCategory(id) == llvm::omp::Category::Declarative};
+ // A directive's "pure" property is version-specific: pureSince is the
+ // OpenMP version at which the directive gained that property.
+ unsigned pureSince{llvm::omp::getDirectivePureSince(id)};
+ if (alwaysAllowed || version >= pureSince) {
----------------
ShashwathiNavada wrote:
Done! I have now marked _simd_ and _declarative directives_ as suggested. Thank you.
https://github.com/llvm/llvm-project/pull/212676
More information about the flang-commits
mailing list