[flang-commits] [flang] e0e2a11 - [flang][runtime] Make ASSOCIATED() conform with standard

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Thu Jun 16 11:39:55 PDT 2022


Author: Peter Klausler
Date: 2022-06-16T11:39:44-07:00
New Revision: e0e2a11751952e3f0d0127ffa52b965a54b51497

URL: https://github.com/llvm/llvm-project/commit/e0e2a11751952e3f0d0127ffa52b965a54b51497
DIFF: https://github.com/llvm/llvm-project/commit/e0e2a11751952e3f0d0127ffa52b965a54b51497.diff

LOG: [flang][runtime] Make ASSOCIATED() conform with standard

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

Differential Revision: https://reviews.llvm.org/D127793

Added: 
    

Modified: 
    flang/runtime/pointer.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/pointer.cpp b/flang/runtime/pointer.cpp
index 7fcb90072e754..843f9165f8554 100644
--- a/flang/runtime/pointer.cpp
+++ b/flang/runtime/pointer.cpp
@@ -165,8 +165,9 @@ bool RTNAME(PointerIsAssociatedWith)(
   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;
     }
   }


        


More information about the flang-commits mailing list