[flang] Answer PR 631 comments:

- Create a function `IsFunctionResult(const Symbol &)` in
   lib/semantics/tools.h.
 - style edit in weird var definition style.

Original-commit: flang-compiler/f18@15e3f87b40
Reviewed-on: https://github.com/flang-compiler/f18/pull/631
Tree-same-pre-rewrite: false
This commit is contained in:
Jean Perier 2019-08-08 03:46:14 -07:00
parent 24bb2c29cd
commit 3b7b2f56d5
3 changed files with 13 additions and 7 deletions

View File

@ -1840,9 +1840,9 @@ static void CheckFuncRefToArrayElementRefHasSubscripts(
if (std::get<std::list<parser::ActualArgSpec>>(funcRef.v.t).empty()) {
auto &proc{std::get<parser::ProcedureDesignator>(funcRef.v.t)};
const auto *name{std::get_if<parser::Name>(&proc.u)};
name = {name
? name
: &std::get<parser::ProcComponentRef>(proc.u).v.thing.component};
if (name == nullptr) {
name = &std::get<parser::ProcComponentRef>(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)};

View File

@ -937,11 +937,15 @@ const Symbol *FindUltimateComponent(const DerivedTypeSpec &derived,
return nullptr;
}
bool IsFunctionResultWithSameNameAsFunction(const Symbol &symbol) {
if ((symbol.has<semantics::ObjectEntityDetails>() &&
bool IsFunctionResult(const Symbol &symbol) {
return (symbol.has<semantics::ObjectEntityDetails>() &&
symbol.get<semantics::ObjectEntityDetails>().isFuncResult()) ||
(symbol.has<semantics::ProcEntityDetails>() &&
symbol.get<semantics::ProcEntityDetails>().isFuncResult())) {
symbol.get<semantics::ProcEntityDetails>().isFuncResult());
}
bool IsFunctionResultWithSameNameAsFunction(const Symbol &symbol) {
if (IsFunctionResult(symbol)) {
if (const Symbol * function{symbol.owner().symbol()}) {
return symbol.name() == function->name();
}

View File

@ -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(