This is an archive of the discontinued LLVM Phabricator instance.

[flang] Error detection/avoidance for TRANSFER with empty MOLD= type
ClosedPublic

Authored by klausler on Jul 13 2022, 11:51 AM.

Details

Summary

When MOLD= is an array and there is no SIZE= in a call to TRANSFER(),
the size of an element of the MOLD= is used as the denominator in a
division to establish the extent of the vector result. When the
total storage size of the SOURCE= is known to be zero, the result is
empty and no division is needed.

To avoid a division by zero at runtime, we need to check for a zero-sized
MOLD= element type when the storage size of SOURCE= is nonzero and there
is no SIZE=. Further, in the compilation-time rewriting of calls to
SHAPE(TRANSFER(...)) and SIZE(TRANSFER(...)) for constant folding and
simplification purposes, we can't replace the call with an arithmetic
element count expression when the storage size of SOURCE= is not known
to be zero and the element size of MOLD= is not known to be nonzero at
compilation time.

These changes mostly affect tests using a MOLD= argument that is an
assumed-length character.

Diff Detail

Event Timeline

klausler created this revision.Jul 13 2022, 11:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2022, 11:51 AM
Herald added a subscriber: jdoerfert. · View Herald Transcript
klausler requested review of this revision.Jul 13 2022, 11:51 AM
vdonaldson accepted this revision.Jul 13 2022, 2:45 PM
This revision is now accepted and ready to land.Jul 13 2022, 2:45 PM