This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix LBOUND rewrite on descriptor components
ClosedPublic

Authored by jeanPerier on Mar 24 2022, 8:41 AM.

Details

Summary

GetLowerBoundHelper rewrite in https://reviews.llvm.org/D121488 was
incorrect with POINTER/ALLOCATABLE components. The rewrite created a
descriptor inquiry to the component symbol only instead of the whole
named entity. The base information was lost, and not retrievable.
LBOUND(a(10)%p) became LBOUND(p).

Fix this regression, and also update DescriptorInquiry unparsing to
carry the kind information. DescriptorInquiries are KIND 8 expressions,
while LBOUND/SIZE/RANK, %LEN are default kind expressions.
This caused print *,lbound(x,kind=8) to unparse as print*,lbound(x) which is not
semantically the same (this unparsing issue was not an issue for
lowering, but I noticed it while writing my regression test).

Diff Detail

Event Timeline

jeanPerier created this revision.Mar 24 2022, 8:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2022, 8:41 AM
Herald added a subscriber: jdoerfert. · View Herald Transcript
jeanPerier requested review of this revision.Mar 24 2022, 8:41 AM
klausler accepted this revision.Mar 24 2022, 8:44 AM
This revision is now accepted and ready to land.Mar 24 2022, 8:44 AM
This revision was automatically updated to reflect the committed changes.