[flang] Rework .mod file writing for subprogram interfaces
authorTim Keith <tkeith@nvidia.com>
Fri, 29 Mar 2019 22:04:17 +0000 (15:04 -0700)
committerTim Keith <tkeith@nvidia.com>
Fri, 29 Mar 2019 22:04:17 +0000 (15:04 -0700)
commitd628a6f983ad9c1c5836d099ca949ef7b81d1e52
tree97cd06345883a214d52c8164b1e596903b91bce7
parentb4dc611eb4061bc6bb4c322b282c7fdff6e9bc20
[flang] Rework .mod file writing for subprogram interfaces

A subprogram interface in a `.mod` file requires all of the symbols
needed to declare the function return value and dummy arguments.
Some of those were missing.

`SubprogramSymbolCollector` recursively discovers all such symbols,
including symbols used in type parameters, array bounds, character
lengths, parent types.

Common blocks require special handling: If any of the symbols that
are need appear in a common block, we have to include that common block
and all other symbols in it. To make that easier to figure out, add the
`commonBlock` property to `ObjectEntityDetails` to map the entity to
the common block it is in, if any.

Original-commit: flang-compiler/f18@08709f8e88c3b37bdf8461f34340dc345dfbb085
Reviewed-on: https://github.com/flang-compiler/f18/pull/368
Tree-same-pre-rewrite: false
flang/lib/semantics/mod-file.cc
flang/lib/semantics/resolve-names.cc
flang/lib/semantics/symbol.h
flang/test/semantics/CMakeLists.txt
flang/test/semantics/modfile04.f90
flang/test/semantics/modfile21.f90
flang/test/semantics/modfile23.f90 [new file with mode: 0644]