<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116844>116844</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Regression for BIND(C) Subprograms, Compiler Asserts
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
jeanPerier
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mjklemm
</td>
</tr>
</table>
<pre>
The following code dies with a compiler assertion, when compiled:
```
$ flang -c reproducer.f90
reproducer.f90:10:12: warning: Function result is never defined
function f0(a0, a1) bind(c, name="f0")
^^
error: loc("'reproducer.f90":21:5): 'llvm.call' op operand type mismatch for operand 2: 'i64' != '!llvm.ptr'
error: Lowering to LLVM IR failed
Call parameter type does not match function signature!
%18 = extractvalue { ptr, i64 } %15, 1
ptr call void @f0(ptr %4, ptr %17, i64 %18, ptr %6)
error: failed to create the LLVM module
```
This seem to is caused by commit 367c3c968eb8f29b55fb8019b2464c7ff6307ca8 and PR #111969.
Reproducer code:
```Fortran
module m
implicit none
type, public, bind(c) :: t
character :: m(256)
end type t
contains
function f0(a0, a1) bind(c, name="f0")
import :: t
character, intent(in) :: a0(*)
integer :: a1
type(t) :: f0
end function
function f1() result(v0)
type(t) :: v0
character, allocatable, target :: v1(:)
integer :: v2
v0 = f0(v1, v2)
end function
end module
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVU-P46gT_TTkUurIxv8PPqSTX6SR-rca9Y72jqFs04vBApze_vYriJ2kRz1zWSlyTFFVr17VwzDn5KARW1I8E0rfkOnvaCVaQikpTju2-NHYdnr7W-E07TojPtofI0JvlDLvUg_AjUAQEh28Sz8CA26mWSq0wJxD66XRhB7hfUS9bQmSHUhyIsn2LJP1d13SHHrF9ABPHCzO1oiFo933zerwky07pPFBSXaAd2a11EN4PS-aB3iw6BblQTrQeEELAnupUVyTAQD0m2efEFqzJBTMUkIb6KQWh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