[flang] Implement semantics for DEC STRUCTURE/RECORD
authorPeter Klausler <pklausler@nvidia.com>
Sat, 18 Dec 2021 00:48:16 +0000 (16:48 -0800)
committerPeter Klausler <pklausler@nvidia.com>
Thu, 13 Jan 2022 21:17:13 +0000 (13:17 -0800)
commitc14cf92b5a1cb13a33786291604c24a42e51b8eb
tree26ff1b65b69fc3becfb57e0993a31a7a0a74ce3f
parent71a082f72674ceba0797748543dcef3620b22822
[flang] Implement semantics for DEC STRUCTURE/RECORD

Implements part of the legacy "DEC structures" feature from
VMS Fortran.  STRUCTUREs are processed as if they were derived
types with SEQUENCE.  DATA-like object entity initialization
is supported as well (e.g., INTEGER FOO/666/) since it was used
for default component initialization in structures.  Anonymous
components (named %FILL) are also supported.

These features, and UNION/MAP, were already being parsed.
An omission in the collection of structure field names in the
case of nested structures with entity declarations was fixed
in the parser.

Structures are supported in modules, but this is mostly for
testing purposes.  The names of fields in structures accessed
via USE association cannot appear with dot notation in client
code (at least not yet).  DEC structures antedate Fortran 90,
so their actual use in applications should not involve modules.

This patch does not implement UNION/MAP, since that feature
would impose difficulties later in lowering them to MLIR types.
In the meantime, if they appear, semantics will issue a
"not yet implemented" error message.

Differential Revision: https://reviews.llvm.org/D117151
26 files changed:
flang/docs/Extensions.md
flang/include/flang/Common/unwrap.h
flang/include/flang/Parser/dump-parse-tree.h
flang/include/flang/Parser/parse-tree.h
flang/include/flang/Parser/tools.h
flang/include/flang/Parser/user-state.h
flang/include/flang/Semantics/expression.h
flang/include/flang/Semantics/semantics.h
flang/include/flang/Semantics/symbol.h
flang/lib/Evaluate/fold-designator.cpp
flang/lib/Parser/Fortran-parsers.cpp
flang/lib/Parser/unparse.cpp
flang/lib/Parser/user-state.cpp
flang/lib/Semantics/check-data.cpp
flang/lib/Semantics/check-data.h
flang/lib/Semantics/data-to-inits.cpp
flang/lib/Semantics/data-to-inits.h
flang/lib/Semantics/mod-file.cpp
flang/lib/Semantics/mod-file.h
flang/lib/Semantics/resolve-names.cpp
flang/lib/Semantics/runtime-type-info.cpp
flang/lib/Semantics/semantics.cpp
flang/lib/Semantics/type.cpp
flang/test/Semantics/modfile42.f90 [new file with mode: 0644]
flang/test/Semantics/struct01.f90 [new file with mode: 0644]
flang/test/Semantics/symbol15.f90