[flang-commits] [PATCH] D125097: [flang] retain binding label of entry subprograms
Jean Perier via Phabricator via flang-commits
flang-commits at lists.llvm.org
Fri May 6 08:02:23 PDT 2022
jeanPerier created this revision.
jeanPerier added reviewers: klausler, PeteSteinfeld.
jeanPerier added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
jeanPerier requested review of this revision.
When processing an entry-stmt in name resolution, attrs_ was
reset before SetBindNameOn was called, causing the symbol to lose
the binding label information.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D125097
Files:
flang/lib/Semantics/resolve-names.cpp
flang/test/Lower/program-units-fir-mangling.f90
Index: flang/test/Lower/program-units-fir-mangling.f90
===================================================================
--- flang/test/Lower/program-units-fir-mangling.f90
+++ flang/test/Lower/program-units-fir-mangling.f90
@@ -151,4 +151,38 @@
! CHECK: }
end function
+! CHECK-LABEL: func @bc1() attributes {fir.sym_name = "_QPbind_c_s"} {
+subroutine bind_c_s() Bind(C,Name='bc1')
+ ! CHECK: return
+end subroutine bind_c_s
+
+! CHECK-LABEL: func @_QPbind_c_s() {
+subroutine bind_c_s()
+ ! CHECK: fir.call @_QPbind_c_q() : () -> ()
+ ! CHECK: return
+ call bind_c_q
+end
+
+! CHECK-LABEL: func @_QPbind_c_q() {
+subroutine bind_c_q()
+ interface
+ subroutine bind_c_s() Bind(C, name='bc1')
+ end
+ end interface
+ ! CHECK: fir.call @bc1() : () -> ()
+ ! CHECK: return
+ call bind_c_s
+end
+
+! Test that BIND(C) label is taken into account for ENTRY symbols.
+! CHECK-LABEL: func @_QPsub_with_entries() {
+subroutine sub_with_entries
+! CHECK-LABEL: func @bar() attributes {fir.sym_name = "_QPsome_entry"} {
+ entry some_entry() bind(c, name="bar")
+! CHECK-LABEL: func @_QPnormal_entry() {
+ entry normal_entry()
+! CHECK-LABEL: func @some_other_entry() attributes {fir.sym_name = "_QPsome_other_entry"} {
+ entry some_other_entry() bind(c)
+end subroutine
+
! CHECK-LABEL: fir.global internal @_QFfooEpi : f32 {
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -837,6 +837,7 @@
const parser::LanguageBindingSpec * = nullptr);
Symbol *GetSpecificFromGeneric(const parser::Name &);
SubprogramDetails &PostSubprogramStmt(const parser::Name &);
+ void PostEntryStmt(const parser::EntryStmt &stmt);
};
class DeclarationVisitor : public ArraySpecVisitor,
@@ -3317,7 +3318,11 @@
}
void SubprogramVisitor::Post(const parser::EntryStmt &stmt) {
- auto attrs{EndAttrs()}; // needs to be called even if early return
+ PostEntryStmt(stmt);
+ EndAttrs();
+}
+
+void SubprogramVisitor::PostEntryStmt(const parser::EntryStmt &stmt) {
Scope &inclusiveScope{InclusiveScope()};
const Symbol *subprogram{inclusiveScope.symbol()};
if (!subprogram) {
@@ -3431,8 +3436,8 @@
Symbol::Flag subpFlag{
inFunction ? Symbol::Flag::Function : Symbol::Flag::Subroutine};
Scope &outer{inclusiveScope.parent()}; // global or module scope
- if (outer.IsModule() && !attrs.test(Attr::PRIVATE)) {
- attrs.set(Attr::PUBLIC);
+ if (outer.IsModule() && attrs_ && !attrs_->test(Attr::PRIVATE)) {
+ attrs_->set(Attr::PUBLIC);
}
if (Symbol * extant{FindSymbol(outer, name)}) {
if (!HandlePreviousCalls(name, *extant, subpFlag)) {
@@ -3446,7 +3451,7 @@
}
}
- Symbol *entrySymbol{&MakeSymbol(outer, name.source, attrs)};
+ Symbol *entrySymbol{&MakeSymbol(outer, name.source, GetAttrs())};
if (auto *generic{entrySymbol->detailsIf<GenericDetails>()}) {
CHECK(generic->specific());
entrySymbol = generic->specific();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125097.427642.patch
Type: text/x-patch
Size: 3041 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220506/f2d5118e/attachment.bin>
More information about the flang-commits
mailing list