diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp index 36deab969456d..71af694fb9512 100644 --- a/flang/lib/Semantics/resolve-names.cpp +++ b/flang/lib/Semantics/resolve-names.cpp @@ -5647,10 +5647,8 @@ void DeclarationVisitor::Post(const parser::ProcInterface &x) { void DeclarationVisitor::Post(const parser::ProcDecl &x) { const auto &name{std::get(x.t)}; const Symbol *procInterface{nullptr}; - if (interfaceName_) { - procInterface = interfaceName_->symbol->has() - ? interfaceName_->symbol->get().specific() - : interfaceName_->symbol; + if (interfaceName_ && interfaceName_->symbol) { + procInterface = &BypassGeneric(*interfaceName_->symbol); } auto attrs{HandleSaveName(name.source, GetAttrs())}; DerivedTypeDetails *dtDetails{nullptr}; diff --git a/flang/test/Semantics/bind-c03.f90 b/flang/test/Semantics/bind-c03.f90 index 03a544b1954d7..65d52e964ca46 100644 --- a/flang/test/Semantics/bind-c03.f90 +++ b/flang/test/Semantics/bind-c03.f90 @@ -13,7 +13,13 @@ subroutine proc2() end end interface + interface proc3 + subroutine proc3() bind(c) + end + end interface + procedure(proc1), bind(c) :: pc1 ! no error + procedure(proc3), bind(c) :: pc4 ! no error !ERROR: An interface name with BIND attribute must be specified if the BIND attribute is specified in a procedure declaration statement procedure(proc2), bind(c) :: pc2