[flang] Implement reading of module files
authorTim Keith <tkeith@nvidia.com>
Wed, 25 Jul 2018 13:55:11 +0000 (06:55 -0700)
committerGitHub <noreply@github.com>
Wed, 25 Jul 2018 17:11:38 +0000 (10:11 -0700)
commitf62f8b655d778ca1ed48e9161ea1405f54822ce5
tree7c7be59478b1f14754f6baa5f8dd720e7b06f60c
parent9381c34f61d4c020820fd1f09e8f164eb7c15049
[flang] Implement reading of module files

When a use-stmt is encountered for a module that isn't in the global
scope, search for and read the appropriate `.mod` file. To perform the
search, pass the search directories in to ResolveNames.

For modules that were read from `.mod` files, we have to keep the cooked
source from being deleted so that the names so that references to names
stay valid. So we store the cooked source in the Scope of the module as
a `unique_ptr`.

Add `Symbol::Flag::ModFile` to distinguish module symbols that were read
from a `.mod` file rather than from the current compilation. Use it to
prevent writing those back out.

Fix test_errors.sh to run the compiler in the temp subdirectory --
otherwise tests could be affected by `.mod` files left from previous
tests.

Original-commit: flang-compiler/f18@207065999ce09ca7361aeb0262d1b8bf8cf4b99e
Reviewed-on: https://github.com/flang-compiler/f18/pull/145
flang/documentation/mod-files.md
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.h
flang/test/semantics/resolve12.f90
flang/test/semantics/test_errors.sh
flang/tools/f18/f18.cc