diff --git a/flang/lib/Evaluate/check-expression.cpp b/flang/lib/Evaluate/check-expression.cpp index 64b118a54aa7..06be4da621bc 100644 --- a/flang/lib/Evaluate/check-expression.cpp +++ b/flang/lib/Evaluate/check-expression.cpp @@ -270,9 +270,6 @@ public: return false; } bool operator()(const StructureConstructor &) const { return false; } - template bool operator()(const FunctionRef &) { - return false; - } template bool operator()(const Operation &) const { return false; @@ -280,7 +277,11 @@ public: template bool operator()(const Parentheses &x) const { return (*this)(x.left()); } - template bool operator()(const FunctionRef &x) const { + bool operator()(const ProcedureRef &x) const { + if (const SpecificIntrinsic * intrinsic{x.proc().GetSpecificIntrinsic()}) { + return intrinsic->characteristics.value().attrs.test( + characteristics::Procedure::Attr::NullPointer); + } return false; } bool operator()(const Relational &) const { return false; } @@ -557,7 +558,7 @@ public: return std::nullopt; } - template Result operator()(const FunctionRef &x) const { + Result operator()(const ProcedureRef &x) const { if (const auto *symbol{x.proc().GetSymbol()}) { const Symbol &ultimate{symbol->GetUltimate()}; if (!semantics::IsPureProcedure(ultimate)) { @@ -708,7 +709,7 @@ public: Result operator()(const ComplexPart &) const { return false; } Result operator()(const Substring &) const { return false; } - template Result operator()(const FunctionRef &x) const { + Result operator()(const ProcedureRef &x) const { if (auto chars{ characteristics::Procedure::Characterize(x.proc(), context_)}) { if (chars->functionResult) { diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp index 7b8da73f404c..405ca251fa86 100644 --- a/flang/lib/Semantics/expression.cpp +++ b/flang/lib/Semantics/expression.cpp @@ -3108,7 +3108,9 @@ bool ExpressionAnalyzer::EnforceTypeConstraint(parser::CharBlock at, MaybeExpr ExpressionAnalyzer::MakeFunctionRef(parser::CharBlock callSite, ProcedureDesignator &&proc, ActualArguments &&arguments) { if (const auto *intrinsic{std::get_if(&proc.u)}) { - if (intrinsic->name == "null" && arguments.empty()) { + if (intrinsic->characteristics.value().attrs.test( + characteristics::Procedure::Attr::NullPointer) && + arguments.empty()) { return Expr{NullPointer{}}; } }