Skip to content

Commit 288072a

Browse files
committed
[Flang] Revise the fix in PR llvm#81807 to get specific procedure from a potential generic name.
1 parent 12ade6f commit 288072a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

flang/include/flang/Semantics/symbol.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,9 @@ class Symbol {
786786
inline Symbol &GetUltimate();
787787
inline const Symbol &GetUltimate() const;
788788

789+
// Get the specific procedure from a potential generic symbol.
790+
inline const Symbol *GetUltimateGeneric() const;
791+
789792
inline DeclTypeSpec *GetType();
790793
inline const DeclTypeSpec *GetType() const;
791794
void SetType(const DeclTypeSpec &);
@@ -985,6 +988,16 @@ inline const Symbol &Symbol::GetUltimate() const {
985988
}
986989
}
987990

991+
inline const Symbol *Symbol::GetUltimateGeneric() const {
992+
if (this->has<GenericDetails>())
993+
return this;
994+
if (const auto *details{detailsIf<UseDetails>()})
995+
return details->symbol().GetUltimateGeneric();
996+
if (const auto *details{detailsIf<HostAssocDetails>()})
997+
return details->symbol().GetUltimateGeneric();
998+
return nullptr;
999+
}
1000+
9881001
inline DeclTypeSpec *Symbol::GetType() {
9891002
return const_cast<DeclTypeSpec *>(
9901003
const_cast<const Symbol *>(this)->GetType());

flang/lib/Semantics/resolve-names.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5644,12 +5644,14 @@ void DeclarationVisitor::Post(const parser::ProcInterface &x) {
56445644
NoteInterfaceName(*name);
56455645
}
56465646
}
5647+
56475648
void DeclarationVisitor::Post(const parser::ProcDecl &x) {
56485649
const auto &name{std::get<parser::Name>(x.t)};
56495650
const Symbol *procInterface{nullptr};
56505651
if (interfaceName_) {
5651-
procInterface = interfaceName_->symbol->has<GenericDetails>()
5652-
? interfaceName_->symbol->get<GenericDetails>().specific()
5652+
const Symbol *ultimateGeneric{interfaceName_->symbol->GetUltimateGeneric()};
5653+
procInterface = ultimateGeneric
5654+
? ultimateGeneric->get<GenericDetails>().specific()
56535655
: interfaceName_->symbol;
56545656
}
56555657
auto attrs{HandleSaveName(name.source, GetAttrs())};

0 commit comments

Comments
 (0)