This is an archive of the discontinued LLVM Phabricator instance.

[flang][runtime] Handle conflicts for derived types with dynamic components.
ClosedPublic

Authored by vzakhari on Jul 26 2023, 1:45 PM.

Details

Summary

When creating a temporary for conflicting LHS and RHS we have to deep copy
the dynamic (allocatable, automatic) components from RHS to the temp.
Otherwise, the conflict may still be present between LHS and temp.

gfortran/regression/alloc_comp_assign_1.f90 is an example where the current
runtime code produces wrong result:
https://github.com/llvm/llvm-test-suite/blob/7b5b5dcbf9bdde729a14722eb67f9c3ab01647c7/Fortran/gfortran/regression/alloc_comp_assign_1.f90#L50

Diff Detail

Event Timeline

vzakhari created this revision.Jul 26 2023, 1:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2023, 1:45 PM
vzakhari requested review of this revision.Jul 26 2023, 1:45 PM
klausler accepted this revision.Jul 26 2023, 2:04 PM
klausler added inline comments.
flang/runtime/derived.cpp
262

I think that this would be more consistent with other runtime code (and perhaps more clear) as:

if (const DescriptorAddendum *addendum{descriptor.Addendum()}) {
  if (const auto *derived{addendum->derivedType()}) {
   const Descriptor &componentDesc{...};
   ...
  }
}
return false;
This revision is now accepted and ready to land.Jul 26 2023, 2:04 PM
vzakhari updated this revision to Diff 544511.Jul 26 2023, 2:08 PM

Thanks for the review! I reordered the code.

vzakhari updated this revision to Diff 544555.Jul 26 2023, 4:37 PM

Fixed a mistype.

vzakhari updated this revision to Diff 544593.Jul 26 2023, 9:41 PM

clang-format

tblah accepted this revision.Jul 27 2023, 1:47 AM

Looks good to me, thanks!