Commit Graph

2 Commits

Author SHA1 Message Date
Valentin Clement f3222be4fc
[flang] Avoid deallocation of intent(out) when dummy arg is not in entry stmt
In some case, the ENTRY statement in a procedure is including some
dummy argument. Until now, deallocation of intent(out) allocatable was
not checking for this and it could result in a segmentation fault.

This patch avoids deallocation when the value is not in the ENTRY stmt.

Reviewed By: jeanPerier, PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D134342
2022-09-21 18:48:09 +02:00
Valentin Clement 273b3350d2
[flang] Deallocate intent(out) allocatables
From Fortran 2018 standard 9.7.3.2 point 6:
When a procedure is invoked, any allocated allocatable object that is an actual
argument corresponding to an INTENT (OUT) allocatable dummy argument is
deallocated; any allocated allocatable object that is a subobject of an actual
argument corresponding to an INTENT (OUT) dummy argument is deallocated.

Deallocation is done on the callee side. For BIND(C) procedure, the deallocation
is also done on the caller side.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D133348
2022-09-08 10:15:54 +02:00