Skip to content

Commit

Permalink
[Flang] Revise the fix in PR llvm#81807 to get specific procedure fro…
Browse files Browse the repository at this point in the history
…m a potential generic name.
  • Loading branch information
DanielCChen committed Feb 21, 2024
1 parent d17eade commit a0875cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 13 additions & 0 deletions flang/include/flang/Semantics/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,9 @@ class Symbol {
inline Symbol &GetUltimate();
inline const Symbol &GetUltimate() const;

// Get the specific procedure from a potential generic symbol.
inline const Symbol *GetUltimateGeneric() const;

inline DeclTypeSpec *GetType();
inline const DeclTypeSpec *GetType() const;
void SetType(const DeclTypeSpec &);
Expand Down Expand Up @@ -985,6 +988,16 @@ inline const Symbol &Symbol::GetUltimate() const {
}
}

inline const Symbol *Symbol::GetUltimateGeneric() const {
if (this->has<GenericDetails>())
return this;
if (const auto *details{detailsIf<UseDetails>()})
return details->symbol().GetUltimateGeneric();
if (const auto *details{detailsIf<HostAssocDetails>()})
return details->symbol().GetUltimateGeneric();
return nullptr;
}

inline DeclTypeSpec *Symbol::GetType() {
return const_cast<DeclTypeSpec *>(
const_cast<const Symbol *>(this)->GetType());
Expand Down
6 changes: 4 additions & 2 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5644,12 +5644,14 @@ void DeclarationVisitor::Post(const parser::ProcInterface &x) {
NoteInterfaceName(*name);
}
}

void DeclarationVisitor::Post(const parser::ProcDecl &x) {
const auto &name{std::get<parser::Name>(x.t)};
const Symbol *procInterface{nullptr};
if (interfaceName_) {
procInterface = interfaceName_->symbol->has<GenericDetails>()
? interfaceName_->symbol->get<GenericDetails>().specific()
const Symbol *ultimateGeneric{interfaceName_->symbol->GetUltimateGeneric()};
procInterface = ultimateGeneric
? ultimateGeneric->get<GenericDetails>().specific()
: interfaceName_->symbol;
}
auto attrs{HandleSaveName(name.source, GetAttrs())};
Expand Down

0 comments on commit a0875cd

Please sign in to comment.