[flang] Only deallocate intent(out) allocatable through runtime if allocated
authorValentin Clement <clementval@gmail.com>
Wed, 11 Jan 2023 08:20:28 +0000 (09:20 +0100)
committerValentin Clement <clementval@gmail.com>
Wed, 11 Jan 2023 08:27:20 +0000 (09:27 +0100)
commitb71bbbb64ff92184e13a793b71982df4cdee0271
treec466974d0a7e7dfbb7bd8129b5a7dbb246f31ef4
parentd9630c34f44d9ab88fcbe5726a153eef03f82476
[flang] Only deallocate intent(out) allocatable through runtime if allocated

Deallocation of intent(out) allocatable was done in D133348. This patch adds
an if guard when the deallocation is done through a runtime call. The runtime
is crashing if the box is not allocated. Call the runtime only if the box is
allocated. This is the case for derived type, polymorphic and unlimited
polymorphic entities.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D141427
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Lower/ConvertVariable.cpp
flang/test/Lower/intentout-deallocate.f90