[flang] Cope with specific procedures with same name as generic

When accessing a specific procedure of a USE-associated generic
interface, we need to allow for the case in which that specific
procedure has the same name as the generic when testing for
its availability in the current scope.

Differential Revision: https://reviews.llvm.org/D96467
This commit is contained in:
peter klausler 2021-02-10 16:28:34 -08:00
parent 585e7a359d
commit 9895ba86a8
1 changed files with 19 additions and 13 deletions

View File

@ -1980,11 +1980,18 @@ const Symbol &ExpressionAnalyzer::AccessSpecific(
} else if (const auto *used{
originalGeneric.detailsIf<semantics::UseDetails>()}) {
const auto &scope{originalGeneric.owner()};
auto iter{scope.find(specific.name())};
if (iter != scope.end() && iter->second->has<semantics::UseDetails>() &&
&iter->second->get<semantics::UseDetails>().symbol() == &specific) {
if (auto iter{scope.find(specific.name())}; iter != scope.end()) {
if (const auto *useDetails{
iter->second->detailsIf<semantics::UseDetails>()}) {
const Symbol &usedSymbol{useDetails->symbol()};
const auto *usedGeneric{
usedSymbol.detailsIf<semantics::GenericDetails>()};
if (&usedSymbol == &specific ||
(usedGeneric && usedGeneric->specific() == &specific)) {
return specific;
} else {
}
}
}
// Create a renaming USE of the specific procedure.
auto rename{context_.SaveTempName(
used->symbol().owner().GetName().value().ToString() + "$" +
@ -1993,7 +2000,6 @@ const Symbol &ExpressionAnalyzer::AccessSpecific(
.try_emplace(rename, specific.attrs(),
semantics::UseDetails{rename, specific})
.first->second;
}
} else {
return specific;
}