Skip to content

Commit

Permalink
[flang] Save CallStmt::typedCall (flang-compiler/f18#879)
Browse files Browse the repository at this point in the history
When `ExpressionAnalyzer::AnalyzeCall` processed a subroutine it was
always returning std::nullopt. Change it to return a `ProcedureRef`
wrapped in an `Expr` so that it can be saved in `CallStmt::typedCall`.

Original-commit: flang-compiler/f18@2cc226f
Reviewed-on: flang-compiler/f18#879
  • Loading branch information
tskeith committed Dec 19, 2019
1 parent b200b24 commit 2e96331
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions flang/lib/semantics/expression.cc
Expand Up @@ -1822,9 +1822,9 @@ MaybeExpr ExpressionAnalyzer::Analyze(
}

void ExpressionAnalyzer::Analyze(const parser::CallStmt &callStmt) {
auto expr{AnalyzeCall(callStmt.v, true)};
if (auto *procRef{UnwrapExpr<ProcedureRef>(expr)}) {
callStmt.typedCall.reset(new ProcedureRef{*procRef});
MaybeExpr expr{AnalyzeCall(callStmt.v, true)};
if (const auto *proc{UnwrapExpr<ProcedureRef>(expr)}) {
callStmt.typedCall.reset(new ProcedureRef{*proc});
}
}

Expand All @@ -1840,8 +1840,12 @@ MaybeExpr ExpressionAnalyzer::AnalyzeCall(
GetCalleeAndArguments(std::get<parser::ProcedureDesignator>(call.t),
analyzer.GetActuals(), isSubroutine)}) {
if (isSubroutine) {
CheckCall(call.source, callee->procedureDesignator, callee->arguments);
// TODO: Package the subroutine call as an expr in the parse tree
if (CheckCall(
call.source, callee->procedureDesignator, callee->arguments)) {
return Expr<SomeType>{
ProcedureRef{std::move(callee->procedureDesignator),
std::move(callee->arguments)}};
}
} else {
return MakeFunctionRef(call.source,
std::move(callee->procedureDesignator),
Expand Down

0 comments on commit 2e96331

Please sign in to comment.