[flang-commits] [flang] [flang] Fix separate MODULE PROCEDURE when binding label exists (PR #82686)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Thu Feb 22 12:39:13 PST 2024
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/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.
>From 892ab43db555a2508766a34c27827414a0acb029 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Thu, 22 Feb 2024 12:36:40 -0800
Subject: [PATCH] [flang] Fix separate MODULE PROCEDURE when binding label
exists
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.
---
flang/lib/Semantics/resolve-names.cpp | 7 ++++++-
flang/test/Semantics/separate-mp02.f90 | 4 ++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 36deab969456d0..131585b067cb70 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -4216,7 +4216,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
diff --git a/flang/test/Semantics/separate-mp02.f90 b/flang/test/Semantics/separate-mp02.f90
index 5d13b6b693c8f7..c63ab6f41a1326 100644
--- a/flang/test/Semantics/separate-mp02.f90
+++ b/flang/test/Semantics/separate-mp02.f90
@@ -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
@@ -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
More information about the flang-commits
mailing list