This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix assignment of parameterized derived types
ClosedPublic

Authored by PeteSteinfeld on Apr 20 2021, 10:11 AM.

Details

Summary

We were erroneously emitting error messages for assignments of derived types
where the associated objects were instantiated with non-constant LEN type
parameters.

I fixed this by adding the member function MightBeAssignmentCompatibleWith() to
the class DerivedTypeSpec and calling it to determine whether it's possible
that objects of parameterized derived types can be assigned to each other. Its
implementation first compares the uninstantiated values of the types. If they
are equal, it then compares the values of the constant instantiated type
parameters.

I added tests to assign04.f90 to exercise this new code.

Diff Detail

Event Timeline

PeteSteinfeld requested review of this revision.Apr 20 2021, 10:11 AM
PeteSteinfeld created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2021, 10:11 AM
PeteSteinfeld added a project: Restricted Project.Apr 20 2021, 10:12 AM
klausler accepted this revision.Apr 20 2021, 10:23 AM
klausler added inline comments.
flang/lib/Semantics/tools.cpp
114–115

Minor: you can decrease the amount of block nesting here now, if you like, with an else if.

This revision is now accepted and ready to land.Apr 20 2021, 10:23 AM
PeteSteinfeld added inline comments.Apr 20 2021, 10:50 AM
flang/lib/Semantics/tools.cpp
114–115

Thanks! I'll do it.