[flang-commits] [flang] [flang][OpenMP][#225225] Add diagnosis on invalid list items in depend(depobj:) clauses (PR #227790)

via flang-commits flang-commits at lists.llvm.org
Wed Oct 7 02:16:46 PDT 2026


================
@@ -5257,17 +5257,57 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Depend &x) {
             "one locator"_err_en_US);
       }
     }
+    // [5.0:256:1-2], [5.1:288:19-20], [5.2:323:1-2]
+    // With the DEPOBJ dependence type, array sections cannot be specified and
+    // the list items must be depend objects (scalar integer variables of kind
+    // omp_depend_kind, which is c_intptr_t). This does not apply on the DEPOBJ
+    // construct itself, where the DEPOBJ dependence type is already disallowed.
+    bool isDepobjType{dir != llvm::omp::OMPD_depobj &&
+        taskDep->GetTaskDepType() ==
+            parser::OmpTaskDependenceType::Value::Depobj};
+    auto checkDepobjVar = [&](const parser::OmpObject &object) {
+      const parser::Designator *designator{GetDesignatorFromObj(object)};
+      if (!designator) {
+        context_.Say(GetContext().clauseSource,
+            "A list item in a DEPEND clause with the DEPOBJ dependence type must be a depend object"_err_en_US);
+        return;
+      }
+      evaluate::ExpressionAnalyzer ea{context_};
+      auto restore{ea.AllowWholeAssumedSizeArray(true)};
+      MaybeExpr expr{ea.Analyze(*designator)};
+      if (!expr) {
+        return;
+      }
+      if (expr->Rank() != 0) {
----------------
ShashwathiNavada wrote:

Small suggestion: For depend(depobj: arr), this Rank() != 0 check also catches whole arrays, not just array sections. Could you reword the diagnostic to indicate that the list item must be a scalar integer of kind omp_depend_kind?

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


More information about the flang-commits mailing list