[flang-commits] [PATCH] D127793: [flang][runtime] Make ASSOCIATED() conform with standard

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Tue Jun 14 14:02:20 PDT 2022


klausler created this revision.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

ASSOCIATED() must be false for zero-sized arrays, and the
strides on a dimension are irrelevant when the extent is unitary.


https://reviews.llvm.org/D127793

Files:
  flang/runtime/pointer.cpp


Index: flang/runtime/pointer.cpp
===================================================================
--- flang/runtime/pointer.cpp
+++ flang/runtime/pointer.cpp
@@ -165,8 +165,9 @@
   for (int j{0}; j < rank; ++j) {
     const Dimension &pDim{pointer.GetDimension(j)};
     const Dimension &tDim{target->GetDimension(j)};
-    if (pDim.Extent() != tDim.Extent() ||
-        pDim.ByteStride() != tDim.ByteStride()) {
+    auto pExtent{pDim.Extent()};
+    if (pExtent == 0 || pExtent != tDim.Extent() ||
+        (pExtent != 1 && pDim.ByteStride() != tDim.ByteStride())) {
       return false;
     }
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127793.436927.patch
Type: text/x-patch
Size: 605 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220614/a4565b6e/attachment-0001.bin>


More information about the flang-commits mailing list