[flang-commits] [flang] [flang][OpenMP] Diagnose task reduction array sections and elements (PR #215997)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Sun Sep 6 13:47:15 PDT 2026


================
@@ -182,6 +180,124 @@ static bool hasPrivatizedArrayElementReduction(
   return false;
 }
 
+static bool
+hasPartialArrayReductionObject(llvm::ArrayRef<Object> reductionObjects,
+                               semantics::SemanticsContext &semaCtx) {
+  for (const Object &object : reductionObjects) {
+    if (!object.ref() || isWholeArraySection(object, semaCtx))
+      continue;
+    if (evaluate::IsArraySection(*object.ref()))
+      return true;
+  }
+  return false;
+}
+
+static void checkTaskModifierPartialArrayReduction(
+    mlir::Location loc, semantics::SemanticsContext &semaCtx,
+    mlir::omp::ReductionModifierAttr reductionMod,
+    llvm::ArrayRef<Object> reductionObjects) {
+  if (reductionMod &&
----------------
tblah wrote:

Agreed. I changed the partial-section validation to inspect each reduction
clause’s own modifier and object list before the clauses are flattened.
I also added a focused diagnostic when reduction clauses have different
effective modifiers, since the current MLIR operation cannot represent
those combinations correctly. Tests cover both clause orders and
equivalent-modifier positive cases.

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


More information about the flang-commits mailing list