[flang-commits] [flang] 9895ba8 - [flang] Cope with specific procedures with same name as generic
peter klausler via flang-commits
flang-commits at lists.llvm.org
Wed Feb 10 17:30:34 PST 2021
Author: peter klausler
Date: 2021-02-10T17:30:22-08:00
New Revision: 9895ba86a842bfea10c731ed6c5ed05d77e30d91
URL: https://github.com/llvm/llvm-project/commit/9895ba86a842bfea10c731ed6c5ed05d77e30d91
DIFF: https://github.com/llvm/llvm-project/commit/9895ba86a842bfea10c731ed6c5ed05d77e30d91.diff
LOG: [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
Added:
Modified:
flang/lib/Semantics/expression.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index 37207e6fde2f..c5ca4126f6be 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -1980,20 +1980,26 @@ 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) {
- return specific;
- } else {
- // Create a renaming USE of the specific procedure.
- auto rename{context_.SaveTempName(
- used->symbol().owner().GetName().value().ToString() + "$" +
- specific.name().ToString())};
- return *const_cast<semantics::Scope &>(scope)
- .try_emplace(rename, specific.attrs(),
- semantics::UseDetails{rename, specific})
- .first->second;
+ 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;
+ }
+ }
}
+ // Create a renaming USE of the specific procedure.
+ auto rename{context_.SaveTempName(
+ used->symbol().owner().GetName().value().ToString() + "$" +
+ specific.name().ToString())};
+ return *const_cast<semantics::Scope &>(scope)
+ .try_emplace(rename, specific.attrs(),
+ semantics::UseDetails{rename, specific})
+ .first->second;
} else {
return specific;
}
More information about the flang-commits
mailing list