Skip to content

[Flang]: Fix to bind(C) procs inside BLOCK construct #82483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion flang/lib/Lower/Mangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
bool underscoring) {
assert((symbol.owner().kind() !=
Fortran::semantics::Scope::Kind::BlockConstruct ||
symbol.has<Fortran::semantics::SubprogramDetails>()) &&
symbol.has<Fortran::semantics::SubprogramDetails>() ||
Fortran::semantics::IsBindCProcedure(symbol)) &&
"block object mangling must specify a scopeBlockIdMap");
ScopeBlockIdMap scopeBlockIdMap;
return mangleName(symbol, scopeBlockIdMap, keepExternalInScope, underscoring);
Expand Down
20 changes: 20 additions & 0 deletions flang/test/Lower/HLFIR/block_bindc_pocs.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
! This test checks bind(c) procs inside BLOCK construct.

!RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s

module m
interface
subroutine test_proc() bind(C)
end subroutine test_proc
end interface
end module m
!CHECK-DAG: %[[S0:.*]] = fir.call @llvm.stacksave.p0() fastmath<contract> : () -> !fir.ref<i8>
!CHECK-DAG: fir.call @test_proc() fastmath<contract> : () -> ()
!CHECK-DAG: fir.call @llvm.stackrestore.p0(%[[S0]]) fastmath<contract> : (!fir.ref<i8>) -> ()
!CHECK-DAG: func.func private @test_proc() attributes {fir.bindc_name = "test_proc"}
subroutine test
BLOCK
use m
call test_proc
END BLOCK
end subroutine test