diff --git a/flang/lib/semantics/expression.cc b/flang/lib/semantics/expression.cc index 49d05b6fa2fb..04721254e77f 100644 --- a/flang/lib/semantics/expression.cc +++ b/flang/lib/semantics/expression.cc @@ -1840,9 +1840,9 @@ static void CheckFuncRefToArrayElementRefHasSubscripts( if (std::get>(funcRef.v.t).empty()) { auto &proc{std::get(funcRef.v.t)}; const auto *name{std::get_if(&proc.u)}; - name = {name - ? name - : &std::get(proc.u).v.thing.component}; + if (name == nullptr) { + name = &std::get(proc.u).v.thing.component; + } auto &msg{context.Say(funcRef.v.source, "Reference to array '%s' with empty subscript list"_err_en_US, name->source)}; diff --git a/flang/lib/semantics/tools.cc b/flang/lib/semantics/tools.cc index 19146eec0bbb..98e70a234d1b 100644 --- a/flang/lib/semantics/tools.cc +++ b/flang/lib/semantics/tools.cc @@ -937,11 +937,15 @@ const Symbol *FindUltimateComponent(const DerivedTypeSpec &derived, return nullptr; } -bool IsFunctionResultWithSameNameAsFunction(const Symbol &symbol) { - if ((symbol.has() && - symbol.get().isFuncResult()) || +bool IsFunctionResult(const Symbol &symbol) { + return (symbol.has() && + symbol.get().isFuncResult()) || (symbol.has() && - symbol.get().isFuncResult())) { + symbol.get().isFuncResult()); +} + +bool IsFunctionResultWithSameNameAsFunction(const Symbol &symbol) { + if (IsFunctionResult(symbol)) { if (const Symbol * function{symbol.owner().symbol()}) { return symbol.name() == function->name(); } diff --git a/flang/lib/semantics/tools.h b/flang/lib/semantics/tools.h index 01055186b976..267aaef27a94 100644 --- a/flang/lib/semantics/tools.h +++ b/flang/lib/semantics/tools.h @@ -62,6 +62,8 @@ bool IsProcedure(const Symbol &); bool IsProcName(const Symbol &symbol); // proc-name bool IsVariableName(const Symbol &symbol); // variable-name bool IsProcedurePointer(const Symbol &); +bool IsFunctionResult(const Symbol &); +bool IsFunctionResultWithSameNameAsFunction(const Symbol &); bool IsExtensibleType(const DerivedTypeSpec *); // Is this a derived type from module with this name? bool IsDerivedTypeFromModule(