[flang] Collect names of internal subprograms of a MainProgram

... as is done for other internal subprograms.

Original-commit: flang-compiler/f18@079f45d51b
Reviewed-on: https://github.com/flang-compiler/f18/pull/167
Tree-same-pre-rewrite: false
This commit is contained in:
Tim Keith 2018-08-08 17:28:16 -07:00
parent 08f0877760
commit 4cd3eb3c4a
1 changed files with 7 additions and 1 deletions

View File

@ -2393,7 +2393,7 @@ void ResolveNamesVisitor::Post(const parser::SpecificationPart &s) {
bool ResolveNamesVisitor::Pre(const parser::MainProgram &x) { bool ResolveNamesVisitor::Pre(const parser::MainProgram &x) {
using stmtType = std::optional<parser::Statement<parser::ProgramStmt>>; 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}; const parser::Name &name{stmt->statement.v};
Symbol &symbol{MakeSymbol(name, MainProgramDetails{})}; Symbol &symbol{MakeSymbol(name, MainProgramDetails{})};
PushScope(Scope::Kind::MainProgram, &symbol); PushScope(Scope::Kind::MainProgram, &symbol);
@ -2401,6 +2401,12 @@ bool ResolveNamesVisitor::Pre(const parser::MainProgram &x) {
} else { } else {
PushScope(Scope::Kind::MainProgram, nullptr); 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; return true;
} }