[flang-commits] [flang] [flang][runtime] Fix SAME_TYPE_AS()/EXTENDS_TYPE_OF() for CLASS(*) (PR #67727)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Thu Sep 28 13:16:35 PDT 2023


================
@@ -130,15 +130,17 @@ void RTNAME(AllocatableApplyMold)(
     // 9.7.1.3 Return so the error can be emitted by AllocatableAllocate.
     return;
   }
+  auto *descAddendum{descriptor.Addendum()};
   descriptor = mold;
   descriptor.set_base_addr(nullptr);
   descriptor.raw().attribute = CFI_attribute_allocatable;
   descriptor.raw().rank = rank;
-  if (auto *descAddendum{descriptor.Addendum()}) {
-    if (const auto *moldAddendum{mold.Addendum()}) {
-      if (const auto *derived{moldAddendum->derivedType()}) {
-        descAddendum->set_derivedType(derived);
-      }
+  if (descAddendum) {
+    if (mold.Addendum()) {
+      // it was copied by operator=() above
+    } else {
+      descriptor.raw().f18Addendum = true;
+      descAddendum->set_derivedType(nullptr);
----------------
vzakhari wrote:

nit: Can we just assert that its original derived type is null?  As I understand, the LHS is supposed to be unlimited polymorphic here and it is unallocated, so its derived type must have been reset to null elsewhere.

https://github.com/llvm/llvm-project/pull/67727


More information about the flang-commits mailing list