[PATCH] D120835: [flang] Handle optional TARGET associate in ASSOCIATED runtime

Jean Perier via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 3 01:12:24 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG392cba8603ef: [flang] Handle optional TARGET associate in ASSOCIATED runtime (authored by jeanPerier).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120835

Files:
  flang/include/flang/Runtime/pointer.h
  flang/runtime/pointer.cpp


Index: flang/runtime/pointer.cpp
===================================================================
--- flang/runtime/pointer.cpp
+++ flang/runtime/pointer.cpp
@@ -147,16 +147,22 @@
 }
 
 bool RTNAME(PointerIsAssociatedWith)(
-    const Descriptor &pointer, const Descriptor &target) {
+    const Descriptor &pointer, const Descriptor *target) {
+  if (!target) {
+    return pointer.raw().base_addr != nullptr;
+  }
+  if (!target->raw().base_addr || target->ElementBytes() == 0) {
+    return false;
+  }
   int rank{pointer.rank()};
-  if (pointer.raw().base_addr != target.raw().base_addr ||
-      pointer.ElementBytes() != target.ElementBytes() ||
-      rank != target.rank()) {
+  if (pointer.raw().base_addr != target->raw().base_addr ||
+      pointer.ElementBytes() != target->ElementBytes() ||
+      rank != target->rank()) {
     return false;
   }
   for (int j{0}; j < rank; ++j) {
     const Dimension &pDim{pointer.GetDimension(j)};
-    const Dimension &tDim{target.GetDimension(j)};
+    const Dimension &tDim{target->GetDimension(j)};
     if (pDim.Extent() != tDim.Extent() ||
         pDim.ByteStride() != tDim.ByteStride()) {
       return false;
Index: flang/include/flang/Runtime/pointer.h
===================================================================
--- flang/include/flang/Runtime/pointer.h
+++ flang/include/flang/Runtime/pointer.h
@@ -105,7 +105,7 @@
 
 // True when the pointer is associated with a specific target.
 bool RTNAME(PointerIsAssociatedWith)(
-    const Descriptor &, const Descriptor &target);
+    const Descriptor &, const Descriptor *target);
 
 } // extern "C"
 } // namespace Fortran::runtime


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120835.412626.patch
Type: text/x-patch
Size: 1650 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220303/13148006/attachment.bin>


More information about the llvm-commits mailing list