This is an archive of the discontinued LLVM Phabricator instance.

[flang] Check for duplicate definitions of defined input/output procedures
ClosedPublic

Authored by PeteSteinfeld on Jun 2 2021, 2:58 PM.

Details

Summary

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.

Diff Detail

Event Timeline

PeteSteinfeld requested review of this revision.Jun 2 2021, 2:58 PM
PeteSteinfeld created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2021, 2:58 PM
PeteSteinfeld added a project: Restricted Project.
klausler accepted this revision.Jun 2 2021, 3:11 PM
klausler added inline comments.
flang/lib/Semantics/check-declarations.cpp
1769

I think you don't need or even want the TypeWithDefinedIo constructor here; just list the arguments. Otherwise it's a copy of a constructed value, not construction in place.

This revision is now accepted and ready to land.Jun 2 2021, 3:11 PM
PeteSteinfeld added inline comments.Jun 2 2021, 4:57 PM
flang/lib/Semantics/check-declarations.cpp
1769

Thanks, Peter.

I can't figure out how to get rid of the name of the type and get things to compile. I get an error message from G++ that says "no matching function ..."

jeanPerier accepted this revision.Jun 3 2021, 5:56 AM

Looks good to me

This revision was landed with ongoing or failed builds.Jun 3 2021, 7:39 AM
This revision was automatically updated to reflect the committed changes.