From 2e9633125ea36faf3112fad205b2e08214b3d278 Mon Sep 17 00:00:00 2001 From: Tim Keith Date: Thu, 19 Dec 2019 09:52:15 -0800 Subject: [PATCH] [flang] Save CallStmt::typedCall (flang-compiler/f18#879) 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@2cc226f66ec51b38056c779494a7b6104557f9a8 Reviewed-on: https://github.com/flang-compiler/f18/pull/879 --- flang/lib/semantics/expression.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/flang/lib/semantics/expression.cc b/flang/lib/semantics/expression.cc index 34194838c575..d58d5c3c902f 100644 --- a/flang/lib/semantics/expression.cc +++ b/flang/lib/semantics/expression.cc @@ -1822,9 +1822,9 @@ MaybeExpr ExpressionAnalyzer::Analyze( } void ExpressionAnalyzer::Analyze(const parser::CallStmt &callStmt) { - auto expr{AnalyzeCall(callStmt.v, true)}; - if (auto *procRef{UnwrapExpr(expr)}) { - callStmt.typedCall.reset(new ProcedureRef{*procRef}); + MaybeExpr expr{AnalyzeCall(callStmt.v, true)}; + if (const auto *proc{UnwrapExpr(expr)}) { + callStmt.typedCall.reset(new ProcedureRef{*proc}); } } @@ -1840,8 +1840,12 @@ MaybeExpr ExpressionAnalyzer::AnalyzeCall( GetCalleeAndArguments(std::get(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{ + ProcedureRef{std::move(callee->procedureDesignator), + std::move(callee->arguments)}}; + } } else { return MakeFunctionRef(call.source, std::move(callee->procedureDesignator),