-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang] preserve pointer rank in polymorphic_pointer => NULL()
The current lowering for polymorphic pointer association was not dealing with NULL in a "context aware" fashion: it was calling the `PointerAssociate` runtime entry point with a fir.box<none> target. But the fir.box<none> is a descriptor for a scalar, this lead the runtime to set the pointer rank to zero, regardless of its actual rank. I do not think there is a way to expose this problem with the Fortran code currently supported by flang, because most further manipulation of the pointer would either set the rank correctly, or do not rely on the rank in the runtime descriptor. However, this is incorrect, and when assumed rank are supported, the following would have failed: ``` subroutine check_rank(p) class(*), pointer :: p(..) p => null() select rank(p) rank (1) print *, "OK" rank default print *, "FAILED" end select end subroutine class(*), pointer :: p(:) p => null() call check_rank(p) end ``` Instead, detect NULL() in polymorphic pointer lowering and trigger the deallocation of the pointer. Differential Revision: https://reviews.llvm.org/D147317
- Loading branch information
1 parent
9d69bca
commit 04a920b
Showing
3 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters