[flang] Add support for submodules
authorTim Keith <tkeith@nvidia.com>
Thu, 2 Aug 2018 23:21:27 +0000 (16:21 -0700)
committerTim Keith <tkeith@nvidia.com>
Thu, 2 Aug 2018 23:21:27 +0000 (16:21 -0700)
commit96b187efdf9af3d966274276d8cf36c3921367d1
tree3f361634104e4a603d8132e59987fd396a5e9339
parent4a20cc8478dd120608ac7077f0d833b98adb880f
[flang] Add support for submodules

Symbols for submodules have `ModuleDetails` with `isSubmodule` set.
Scopes for submodules have `Module` kind and have a parent scope that
is also `Module` kind.

Scopes for modules now contain a mapping of submodule name to scope
so that we can find them without having to search the scope tree or
re-read their `.mod` file.

The module file for submodule `s` with ancestor module `m` is named `m-s.mod`.
The tree structure of scopes means module file writing is now recursive.
Similarly, reading the module file for a submodule may require reading
the module files of its parent and ancestor. `ResolveNames` now requires
the parent scope to be passed in -- it is not always the global scope.

`test_modfiles.sh` now handles an argument that is a filename glob so
that the test can involve multiple files. This allows `modfile09` to
test reading of `.mod` files for modules and submodules.

Original-commit: flang-compiler/f18@2e4424dbc8cc5803d561274dbf70005afe7e65dc
Reviewed-on: https://github.com/flang-compiler/f18/pull/160
Tree-same-pre-rewrite: false
17 files changed:
flang/lib/semantics/mod-file.cc
flang/lib/semantics/mod-file.h
flang/lib/semantics/resolve-names.cc
flang/lib/semantics/resolve-names.h
flang/lib/semantics/scope.cc
flang/lib/semantics/scope.h
flang/lib/semantics/symbol.cc
flang/lib/semantics/symbol.h
flang/test/semantics/CMakeLists.txt
flang/test/semantics/modfile09-a.f90 [new file with mode: 0644]
flang/test/semantics/modfile09-b.f90 [new file with mode: 0644]
flang/test/semantics/modfile09-c.f90 [new file with mode: 0644]
flang/test/semantics/modfile09-d.f90 [new file with mode: 0644]
flang/test/semantics/resolve26.f90 [new file with mode: 0644]
flang/test/semantics/resolve27.f90 [new file with mode: 0644]
flang/test/semantics/test_modfile.sh
flang/tools/f18/f18.cc