[flang] Collect names of internal subprograms of a MainProgram
authorTim Keith <tkeith@nvidia.com>
Thu, 9 Aug 2018 00:28:16 +0000 (17:28 -0700)
committerTim Keith <tkeith@nvidia.com>
Thu, 9 Aug 2018 22:25:45 +0000 (15:25 -0700)
... as is done for other internal subprograms.

Original-commit: flang-compiler/f18@079f45d51b64bcee1197c65201dc66d14ee7c08c
Reviewed-on: https://github.com/flang-compiler/f18/pull/167
Tree-same-pre-rewrite: false

flang/lib/semantics/resolve-names.cc

index 8e891d7..530dcd8 100644 (file)
@@ -2393,7 +2393,7 @@ void ResolveNamesVisitor::Post(const parser::SpecificationPart &s) {
 
 bool ResolveNamesVisitor::Pre(const parser::MainProgram &x) {
   using stmtType = std::optional<parser::Statement<parser::ProgramStmt>>;
-  if (const stmtType &stmt = std::get<stmtType>(x.t)) {
+  if (auto &stmt{std::get<stmtType>(x.t)}) {
     const parser::Name &name{stmt->statement.v};
     Symbol &symbol{MakeSymbol(name, MainProgramDetails{})};
     PushScope(Scope::Kind::MainProgram, &symbol);
@@ -2401,6 +2401,12 @@ bool ResolveNamesVisitor::Pre(const parser::MainProgram &x) {
   } else {
     PushScope(Scope::Kind::MainProgram, nullptr);
   }
+  if (auto &subpPart{
+          std::get<std::optional<parser::InternalSubprogramPart>>(x.t)}) {
+    subpNamesOnly_ = SubprogramKind::Internal;
+    parser::Walk(*subpPart, *static_cast<ResolveNamesVisitor *>(this));
+    subpNamesOnly_ = std::nullopt;
+  }
   return true;
 }