[flang-commits] [PATCH] D114084: [flang] Check ArrayRef base for contiguity in IsSimplyContiguousHelper

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Nov 17 09:20:02 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG394d6fcf3eb9: [flang] Check ArrayRef base for contiguity in IsSimplyContiguousHelper (authored by jeanPerier).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114084/new/

https://reviews.llvm.org/D114084

Files:
  flang/lib/Evaluate/check-expression.cpp
  flang/test/Semantics/assign03.f90


Index: flang/test/Semantics/assign03.f90
===================================================================
--- flang/test/Semantics/assign03.f90
+++ flang/test/Semantics/assign03.f90
@@ -277,6 +277,8 @@
     logical, parameter :: l4 = is_contiguous(x%a(:,v))
     !ERROR: Must be a constant value
     logical, parameter :: l5 = is_contiguous(y(v,1)%a(1,1))
+    !ERROR: Must be a constant value
+    logical, parameter :: l6 = is_contiguous(p(:))
   end
   subroutine test3(b)
     integer, intent(inout) :: b(..)
Index: flang/lib/Evaluate/check-expression.cpp
===================================================================
--- flang/lib/Evaluate/check-expression.cpp
+++ flang/lib/Evaluate/check-expression.cpp
@@ -678,8 +678,15 @@
     if (!(*this)(symbol).has_value()) {
       return false;
     } else if (auto rank{CheckSubscripts(x.subscript())}) {
-      // a(:)%b(1,1) is not contiguous; a(1)%b(:,:) is
-      return *rank > 0 || x.Rank() == 0;
+      if (x.Rank() == 0) {
+        return true;
+      } else if (*rank > 0) {
+        // a(1)%b(:,:) is contiguous if an only if a(1)%b is contiguous.
+        return (*this)(x.base());
+      } else {
+        // a(:)%b(1,1) is not contiguous.
+        return false;
+      }
     } else {
       return false;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114084.387962.patch
Type: text/x-patch
Size: 1285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20211117/d4b55c86/attachment.bin>


More information about the flang-commits mailing list