Skip to content

Commit 8f14149

Browse files
authored
[flang] Fix separate MODULE PROCEDURE when binding label exists (#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.
1 parent 17ede03 commit 8f14149

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4218,7 +4218,12 @@ bool SubprogramVisitor::BeginMpSubprogram(const parser::Name &name) {
42184218
EraseSymbol(name);
42194219
Symbol &newSymbol{MakeSymbol(name, SubprogramDetails{})};
42204220
PushScope(Scope::Kind::Subprogram, &newSymbol);
4221-
newSymbol.get<SubprogramDetails>().set_moduleInterface(*symbol);
4221+
auto &newSubprogram{newSymbol.get<SubprogramDetails>()};
4222+
newSubprogram.set_moduleInterface(*symbol);
4223+
auto &subprogram{symbol->get<SubprogramDetails>()};
4224+
if (const auto *name{subprogram.bindName()}) {
4225+
newSubprogram.set_bindName(std::string{*name});
4226+
}
42224227
newSymbol.attrs() |= symbol->attrs();
42234228
newSymbol.set(symbol->test(Symbol::Flag::Subroutine)
42244229
? Symbol::Flag::Subroutine

flang/test/Semantics/separate-mp02.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ module subroutine s5() bind(c)
148148
end
149149
module subroutine s6() bind(c)
150150
end
151+
module subroutine s7() bind(c, name="s7")
152+
end
151153
end interface
152154
end
153155

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

177181

0 commit comments

Comments
 (0)