[flang-commits] [flang] [flang][OpenMP] Make sure that exec METADIRECTIVE is in execution part (PR #233147)

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Tue Oct 20 08:55:52 PDT 2026


================
@@ -280,6 +282,39 @@ void CanonicalizationOfOmp::CanonicalizeUtilityDirectives(
   }
 }
 
+static bool IsExecutableOrNothing(const parser::OmpDirectiveSpecification &x) {
+  llvm::omp::Directive dirId = x.DirId();
+  if (dirId == llvm::omp::Directive::OMPD_nothing) {
+    return true;
+  }
+  return llvm::omp::getDirectiveCategory(dirId) ==
+      llvm::omp::Category::Executable;
+}
+
+static bool IsExecutable(const parser::OmpMetadirectiveDirective &md) {
+  for (const parser::OmpClause &clause : md.v.Clauses().v) {
+    if (auto *other = parser::Unwrap<parser::OmpOtherwiseClause>(clause)) {
+      if (other->v.has_value() && !IsExecutableOrNothing(other->v->value())) {
+        return false;
----------------
kparzysz wrote:

I'm not sure how we can handle a mixture of declarative and executable directive variants.  The spec doesn't prohibit that, but I'd be ok with having a limitation in flang that it either all-declarative or all-executable.

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


More information about the flang-commits mailing list