Skip to content

Commit f4215f7

Browse files
authored
[flang] Fix handling of shadowed procedure name used as interface (#82837)
Use BypassGeneric() to process the name of an interface in a procedure declaration statement, so that if it's the name of a generic with a homonymous specific procedure, that's what defines the interface. Fixes #82267.
1 parent ed0aa34 commit f4215f7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5658,10 +5658,8 @@ void DeclarationVisitor::Post(const parser::ProcInterface &x) {
56585658
void DeclarationVisitor::Post(const parser::ProcDecl &x) {
56595659
const auto &name{std::get<parser::Name>(x.t)};
56605660
const Symbol *procInterface{nullptr};
5661-
if (interfaceName_) {
5662-
procInterface = interfaceName_->symbol->has<GenericDetails>()
5663-
? interfaceName_->symbol->get<GenericDetails>().specific()
5664-
: interfaceName_->symbol;
5661+
if (interfaceName_ && interfaceName_->symbol) {
5662+
procInterface = &BypassGeneric(*interfaceName_->symbol);
56655663
}
56665664
auto attrs{HandleSaveName(name.source, GetAttrs())};
56675665
DerivedTypeDetails *dtDetails{nullptr};

flang/test/Semantics/bind-c03.f90

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ subroutine proc2()
1313
end
1414
end interface
1515

16+
interface proc3
17+
subroutine proc3() bind(c)
18+
end
19+
end interface
20+
1621
procedure(proc1), bind(c) :: pc1 ! no error
22+
procedure(proc3), bind(c) :: pc4 ! no error
1723

1824
!ERROR: An interface name with BIND attribute must be specified if the BIND attribute is specified in a procedure declaration statement
1925
procedure(proc2), bind(c) :: pc2

0 commit comments

Comments
 (0)