This is an archive of the discontinued LLVM Phabricator instance.

[flang] Handle optional TARGET associate in ASSOCIATED runtime
ClosedPublic

Authored by jeanPerier on Mar 2 2022, 10:47 AM.

Details

Summary

The TARGET argument of ASSOCIATED may be dynamically optional, in which
case ASSOCIATED(POINTER, TARGET) is equal to ASSOCIATED(TARGET).

Make the runtime argument a pointer so that it can detect and handle
arguments that are dynamically optional.

Also fix the runtime to check if TARGET base address is not null and if
its element size is not null to match the requirement of ASSOCIATED
regarding TARGET:

  • if TARGET is an object: true iff [..] TARGET is not a zerosized storage sequence
  • if TARGET is a POINTER: true iff [..] POINTER and TARGET are associated

Not that ASSOCIATED will also returns false if TARGET is an unallocated allocatable.
This is not described in the standard, but is a unanimous behaviour of
existing compilers.

Diff Detail

Event Timeline

jeanPerier created this revision.Mar 2 2022, 10:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 2 2022, 10:47 AM
Herald added a subscriber: jdoerfert. · View Herald Transcript
jeanPerier requested review of this revision.Mar 2 2022, 10:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 2 2022, 10:47 AM
klausler accepted this revision.Mar 2 2022, 10:50 AM
This revision is now accepted and ready to land.Mar 2 2022, 10:50 AM