[flang] Fix bug in rewriting function reference

`a(i)` is parsed as a function reference and needs to be converted to an
array element reference when `a` is an object entity. That determination
was wrong if the symbol for `a` was a symbol representing host-association
or use-association. In that case we need to get to the original symbol
by calling `GetUltimate()` on the symbol.

This was causing symbol09.f90 to get a compilation error because an
array element reference looked like a call to a non-pure function, which
is prohibited inside a DO CONCURRENT.

Original-commit: flang-compiler/f18@221e6c52c5
Reviewed-on: https://github.com/flang-compiler/f18/pull/216
This commit is contained in:
Tim Keith 2018-10-24 13:38:45 -07:00
parent c873638052
commit e064f4f4b9
1 changed files with 2 additions and 1 deletions

View File

@ -83,7 +83,8 @@ private:
}
parser::Name *name{std::get_if<parser::Name>(
&std::get<parser::ProcedureDesignator>((*funcRef)->v.t).u)};
if (!name || !name->symbol || !name->symbol->has<ObjectEntityDetails>()) {
if (!name || !name->symbol ||
!name->symbol->GetUltimate().has<ObjectEntityDetails>()) {
return;
}
x.u = common::Indirection{(*funcRef)->ConvertToArrayElementRef()};