[flang] Only apply PointerIsAssociatedWith fix for derived-type
authorValentin Clement <clementval@gmail.com>
Thu, 9 Mar 2023 15:05:57 +0000 (16:05 +0100)
committerValentin Clement <clementval@gmail.com>
Thu, 9 Mar 2023 15:06:34 +0000 (16:06 +0100)
Only apply the change made in D145604 for derived-type.
zero-sized character for example are supposed to give a false result

Reviewed By: PeteSteinfeld

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

flang/runtime/pointer.cpp

index a0a11e9..216e8c7 100644 (file)
@@ -206,7 +206,8 @@ bool RTNAME(PointerIsAssociatedWith)(
   if (!target) {
     return pointer.raw().base_addr != nullptr;
   }
-  if (!target->raw().base_addr) {
+  if (!target->raw().base_addr ||
+      (target->raw().type != CFI_type_struct && target->ElementBytes() == 0)) {
     return false;
   }
   int rank{pointer.rank()};