[flang] Fix assignment of parameterized derived types
authorPeter Steinfeld <psteinfeld@nvidia.com>
Tue, 20 Apr 2021 17:11:03 +0000 (10:11 -0700)
committerPeter Steinfeld <psteinfeld@nvidia.com>
Tue, 20 Apr 2021 19:41:52 +0000 (12:41 -0700)
commitd667b96c98438edcc00ec85a3b151ac2dae862f3
tree315d5dae8c7c7d181f494bc1d072203951d6d835
parent167da6c9e826b9befc27b6f5a6c540f7f28b7d5a
[flang] Fix assignment of parameterized derived types

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.

Differential Revision: https://reviews.llvm.org/D100868
flang/include/flang/Semantics/type.h
flang/lib/Semantics/tools.cpp
flang/lib/Semantics/type.cpp
flang/test/Semantics/assign04.f90