This is an archive of the discontinued LLVM Phabricator instance.

[flang] Set declared type when NULLIFY a polymorphic pointer
ClosedPublic

Authored by clementval on Oct 28 2022, 6:41 AM.

Details

Summary

Fortran standard 7.3.2.3 point 7 mentions that a diassociated
pointer dynamic type is its declared type.
in 9.7.2 note 1, when a NULLIFY statement is applied to a polymorphic pointer,
its dynamic type becomes the same as its declared type.
This patch enforce these standard points by calling the runtime function
PointerNullifyDerived with the declared type descriptor.

Diff Detail

Event Timeline

clementval created this revision.Oct 28 2022, 6:41 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
Herald added a subscriber: mehdi_amini. · View Herald Transcript
clementval requested review of this revision.Oct 28 2022, 6:41 AM
jeanPerier added inline comments.Oct 28 2022, 8:12 AM
flang/lib/Lower/Bridge.cpp
2207

I am not sure what are the requirements for the other cases where "disassociateMutableBox" is called (like for p => Null), but I am wondering if this should not be done in disassociateMutableBox.
I am OK to have this only done here until it is clear what are the requirements for the other contexts where it is called.

2214

Shouldn't you "continue" the loop here to not call disassociateMutableBox ?

clementval added inline comments.Oct 28 2022, 11:35 AM
flang/lib/Lower/Bridge.cpp
2207

The standard is not really precise on this point but I think it can make sense to do it anyway. I'll move it to disassociateMutableBox so it is a more generic.

2214

Yeah we can skip it since the runtime function does the same.

Address review comment

clementval marked 2 inline comments as done.Oct 28 2022, 11:52 AM
This revision is now accepted and ready to land.Oct 31 2022, 2:07 AM