forked from OSchip/llvm-project
[flang] retain binding label of entry subprograms
When processing an entry-stmt in name resolution, attrs_ was reset before SetBindNameOn was called, causing the symbol to lose the binding label information. Differential Revision: https://reviews.llvm.org/D125097
This commit is contained in:
parent
a4190037fa
commit
ed0341788a
|
@ -841,6 +841,7 @@ private:
|
|||
const parser::LanguageBindingSpec * = nullptr);
|
||||
Symbol *GetSpecificFromGeneric(const parser::Name &);
|
||||
SubprogramDetails &PostSubprogramStmt(const parser::Name &);
|
||||
void PostEntryStmt(const parser::EntryStmt &stmt);
|
||||
};
|
||||
|
||||
class DeclarationVisitor : public ArraySpecVisitor,
|
||||
|
@ -3321,7 +3322,11 @@ SubprogramDetails &SubprogramVisitor::PostSubprogramStmt(
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -3435,8 +3440,8 @@ void SubprogramVisitor::Post(const parser::EntryStmt &stmt) {
|
|||
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)) {
|
||||
|
@ -3450,7 +3455,7 @@ void SubprogramVisitor::Post(const parser::EntryStmt &stmt) {
|
|||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -151,4 +151,38 @@ function alpha() bind(c, name =" bEtA ")
|
|||
! 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 {
|
||||
|
|
Loading…
Reference in New Issue