[flang-commits] [flang] [flang][hlfir] Fixed missing deallocation for components of function … (PR #67768)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Fri Sep 29 08:41:48 PDT 2023


================
@@ -451,34 +473,24 @@ fir::ExtendedValue Fortran::lower::genCallOpAndResult(
           fir::runtime::genDerivedTypeDestroy(*bldr, loc,
                                               fir::getBase(*allocatedResult));
         });
-        cleanupWithDestroy = true;
       } else {
         const Fortran::semantics::DerivedTypeSpec &typeSpec =
             retTy->GetDerivedTypeSpec();
-        if (Fortran::semantics::IsFinalizable(typeSpec)) {
+        // If the result type is finalizable or may require finalization
+        // or have allocatable components, we need to make sure
+        // everything is properly finalized/deallocated.
+        if (Fortran::semantics::IsFinalizable(typeSpec) ||
+            Fortran::semantics::MayRequireFinalization(typeSpec) ||
----------------
vzakhari wrote:

Thank you for the catch.  I removed it.

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


More information about the flang-commits mailing list