This is an archive of the discontinued LLVM Phabricator instance.

[flang] Handle correctly user defined assignment for allocatable component
ClosedPublic

Authored by clementval on Apr 7 2023, 10:56 AM.

Details

Summary

In the Fortran standard 2018 section 10.2.1.3 (13), it is mentioned
that all noncoarray allocatable component must follow this sequence of
operations:

  1. If the component of the variable is allocated, it is deallocated.
  2. If the component of the value of expr is allocated, the corresponding component of the variable is allocated with the same dynamic type and type parameters as the component of the value of expr. If it is an array, it is allocated with the same bounds. The value of the component of the value of expr is then assigned to the corresponding component of the variable using defined assignment if the declared type of the component has a type-bound defined assignment consistent with the component, and intrinsic assignment for the dynamic type of that component otherwise.

This patch updates the code to make use of the user defined assignment for
allocatable component and make sure the component is allocated correctly.

Diff Detail

Event Timeline

clementval created this revision.Apr 7 2023, 10:56 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 7 2023, 10:56 AM
Herald added a subscriber: sunshaoce. · View Herald Transcript
clementval requested review of this revision.Apr 7 2023, 10:56 AM
klausler accepted this revision.Apr 7 2023, 10:59 AM

LGTM and thanks for the correction.

This revision is now accepted and ready to land.Apr 7 2023, 10:59 AM