Skip to content

Commit

Permalink
[flang] Fix separate MODULE PROCEDURE when binding label exists (llvm…
Browse files Browse the repository at this point in the history
…#82686)

When a separate module procedure is defined with a MODULE PROCEDURE and
its corresponding interface has a binding label, the compiler was
emitting an error about mismatching binding labels because the binding
label wasn't being copied into the subprogram's definition.
  • Loading branch information
klausler authored Mar 1, 2024
1 parent 17ede03 commit 8f14149
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4218,7 +4218,12 @@ bool SubprogramVisitor::BeginMpSubprogram(const parser::Name &name) {
EraseSymbol(name);
Symbol &newSymbol{MakeSymbol(name, SubprogramDetails{})};
PushScope(Scope::Kind::Subprogram, &newSymbol);
newSymbol.get<SubprogramDetails>().set_moduleInterface(*symbol);
auto &newSubprogram{newSymbol.get<SubprogramDetails>()};
newSubprogram.set_moduleInterface(*symbol);
auto &subprogram{symbol->get<SubprogramDetails>()};
if (const auto *name{subprogram.bindName()}) {
newSubprogram.set_bindName(std::string{*name});
}
newSymbol.attrs() |= symbol->attrs();
newSymbol.set(symbol->test(Symbol::Flag::Subroutine)
? Symbol::Flag::Subroutine
Expand Down
4 changes: 4 additions & 0 deletions flang/test/Semantics/separate-mp02.f90
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ module subroutine s5() bind(c)
end
module subroutine s6() bind(c)
end
module subroutine s7() bind(c, name="s7")
end
end interface
end

Expand All @@ -172,6 +174,8 @@ module subroutine s5() bind(c, name=" s5")
!ERROR: Module subprogram 's6' has binding label 'not_s6' but the corresponding interface body has 's6'
module subroutine s6() bind(c, name="not_s6")
end
module procedure s7
end
end


Expand Down

0 comments on commit 8f14149

Please sign in to comment.