[flang] Fix failure to resolve submodule name.
authorTim Keith <tkeith@nvidia.com>
Wed, 24 Oct 2018 00:09:26 +0000 (17:09 -0700)
committerTim Keith <tkeith@nvidia.com>
Fri, 26 Oct 2018 14:16:00 +0000 (07:16 -0700)
If we have `SUBMODULE(m:s1) s2` and `s1` is already in memory (i.e. does
not need to be read from the `m-s1.mod` file), we still need to record
the fact that the name is a reference to that module symbol.

Original-commit: flang-compiler/f18@4bb42ed6a4f7da9772903bd411146b989aff8367
Reviewed-on: https://github.com/flang-compiler/f18/pull/218
Tree-same-pre-rewrite: false

flang/lib/semantics/mod-file.cc

index 14a8666..68ecede 100644 (file)
@@ -465,6 +465,7 @@ Scope *ModFileReader::Read(const SourceName &name, Scope *ancestor) {
   std::string ancestorName;  // empty for module
   if (ancestor) {
     if (auto *scope{ancestor->FindSubmodule(name)}) {
+      scope->symbol()->add_occurrence(name);
       return scope;
     }
     ancestorName = ancestor->name().ToString();