[flang-commits] [flang] [flang][OpenACC] Reland data-clause designator path handling (PR #220781)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Thu Oct 8 19:58:36 PDT 2026
================
@@ -0,0 +1,496 @@
+//===-- lib/Evaluate/designator-path.cpp ---------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Evaluate/designator-path.h"
+#include "flang/Common/idioms.h"
+#include "flang/Evaluate/fold.h"
+#include "flang/Evaluate/tools.h"
+#include "flang/Semantics/symbol.h"
+#include <cstdint>
+
+namespace Fortran::evaluate {
+
+namespace {
+// The values selected by a subscript with constant bounds and stride, as the
+// ascending arithmetic progression first, first + stride, ..., last.
+struct ConstantSection {
+ std::int64_t first;
+ std::int64_t last;
+ std::int64_t stride;
+};
+
+struct ConstantSubscriptRange {
+ std::int64_t lower;
+ std::int64_t upper;
+};
+} // namespace
+
+static DesignatorRelation ComparePartSymbols(const Symbol *x, const Symbol *y) {
+ if (x == y) {
+ return DesignatorRelation::Equal;
+ }
+ if (!x) {
+ return DesignatorRelation::Contains;
+ }
+ if (!y) {
+ return DesignatorRelation::ContainedBy;
+ }
+ return DesignatorRelation::Disjoint;
+}
+
+static bool IsFullTriplet(const Triplet &triplet) {
+ // Surface syntax `x(:)` maps to a Triplet with no lower or upper bound and
+ // an implicit stride of one.
+ auto stride{ToInt64(triplet.GetStride())};
+ return !triplet.GetLower() && !triplet.GetUpper() && stride && *stride == 1;
----------------
eugeneepshteyn wrote:
(This comment was generated with the help of AI)
Non-blocking: whole-object subsumption recognizes only the bare `:` spelling, so the same program is accepted or rejected depending on how the full section is written:
```fortran
subroutine s1(a, i)
real :: a(10)
integer :: i
!$acc parallel private(a(i)) private(a(:))
a(3) = 1.0
!$acc end parallel
end subroutine
subroutine s2(a, i)
real :: a(10)
integer :: i
!$acc parallel private(a(i)) private(a(1:10))
a(3) = 1.0
!$acc end parallel
end subroutine
```
`s1` warns and keeps the whole array; `s2` is rejected with the not-yet-implemented message, though `a(1:10)` and `a(:)` select the same elements. Treating a constant section equal to the declared extent as a full slice (where the bounds are constant) would make the two spellings agree. Fine as a follow-up; the new message itself is a clear improvement — it no longer claims the parts are separate.
https://github.com/llvm/llvm-project/pull/220781
More information about the flang-commits
mailing list