[flang] Check for duplicate definitions of defined input/output procedures
authorPeter Steinfeld <psteinfeld@nvidia.com>
Wed, 2 Jun 2021 21:55:41 +0000 (14:55 -0700)
committerPeter Steinfeld <psteinfeld@nvidia.com>
Thu, 3 Jun 2021 14:39:27 +0000 (07:39 -0700)
commit22d7e298dc35a2319d7b71ee78732b0a3a86893d
treeab66ab9e84fdacecbc12c38a52d2387d64f5e692
parent83235b07e3c9c2d21a574465287150e7bf750001
[flang] Check for duplicate definitions of defined input/output procedures

It's possible to specify defined input/output procedures either as a
type-bound procedure of a derived type or as a defined-io-generic-spec.  This
means that you can specify the same procedure in both mechanisms, which does
not cause problems.  Alternatively, you can specify two different procedures to
be the defined input/output procedure for the same derived type.  This is an
error.  This change catches this error.  The situation is slightly complicated
by parameterized derived types.  Types with the same value for a KIND parameter
are treated as the same type while types with different KIND parameters are
treated as different types.

I implemented this check by adding a vector to keep track of which defined
input/output procedures had been seen for which derived types along with the
kind of procedure (read vs write and formatted vs unformatted).  I also added
tests for non-parameterized types and types parameterized by KIND and LEN type
parameters.

I also removed an erroneous check from the code that creates runtime type
information.

Differential Revision: https://reviews.llvm.org/D103560
flang/lib/Semantics/check-declarations.cpp
flang/lib/Semantics/runtime-type-info.cpp
flang/test/Semantics/io11.f90