[flang] Fix name resolution with directly recursive calls.

Original-commit: flang-compiler/f18@b8e8610430
Reviewed-on: https://github.com/flang-compiler/f18/pull/557
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2019-07-10 15:04:39 -07:00
parent 2ccba3837d
commit caf9e8e624
2 changed files with 5 additions and 3 deletions

View File

@ -1573,7 +1573,6 @@ MaybeExpr ExpressionAnalyzer::Analyze(
if (MaybeExpr funcRef{MakeFunctionRef(std::move(*callee))}) {
return funcRef;
}
Say("Subroutine called as if it were a function"_err_en_US);
}
return std::nullopt;
}

View File

@ -1584,9 +1584,12 @@ void ScopeHandler::PushScope(Scope &scope) {
// Create a dummy symbol so we can't create another one with the same
// name. It might already be there if we previously pushed the scope.
if (!FindInScope(scope, symbol->name())) {
auto &newSymbol{CopySymbol(symbol->name(), *symbol)};
auto &newSymbol{MakeSymbol(symbol->name())};
if (kind == Scope::Kind::Subprogram) {
newSymbol.set_details(symbol->get<SubprogramDetails>());
// Allow for recursive references. If this symbol is a function
// without an explicit RESULT(), this new symbol will be discarded
// and replaced with an object of the same name.
newSymbol.set_details(HostAssocDetails{*symbol});
} else {
newSymbol.set_details(MiscDetails{MiscDetails::Kind::ScopeName});
}