<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/81786>81786</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] function reference passed to extends_type_of intrinsic is not called
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
flang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kkwli
</td>
</tr>
</table>
<pre>
Reproducer
```fortran
module m
type Base
integer i
contains
final :: finalizeBase
end type
type, extends(Base) :: Child
contains
final :: finalizeChild
end type
contains
subroutine finalizeBase(b)
type(Base), intent(inout) :: b
print *, "finalizeBase"
end subroutine
subroutine finalizeChild(c)
type(Child), intent(inout) :: c
print *, "finalizeChild"
end subroutine
function func1()
class(Base), allocatable :: func1
allocate(Base::func1)
print*, 'func1 ...'
end function
end module
program main
use m
type(Base) :: arg1
logical :: l
l = extends_type_of(func1(), arg1)
end
```
The expected output is `func1` is called as well as `finalizeBase` due to finalization of the function result.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMlNtunDAQhp_G3FhBxgssXHCxyWofoOp9ZOyBdWNs5EOT9Okrc1jYbdVUisJ6mPnn8_g3zDnZa4AGFc-oOCcs-Kuxzdvbu5JJa8Rn8w1Ga0TgYBE5I3JCJZn_OmO9ZXqODkYEBXiYVxj7zxHwM3OwBjCW2kMPFss1xI32TGq3pXRSM4XR4YQOp3khf8FeBbSYpPdtEH3B8OFBC4doNWXTehV5uUolluz_7LcveWg4_3_QcaG1Jnip4R6ZVi2i9dZsZl0BI3WciPaIVlKb4HfU7VY1Wqk9RvQUCxCl9y3onnMDWaN_QZt3Ryu-sS1gy5t_k_GvyRadL9C6oLmXRk8_MkSru1lxxZy7HxZTynDmWavgdmJT6Vy0vL5NeMpYtOsH6BvzcUrAaZoietzzrnRzLEZmg-9tMFrTWzbggUm91gb3cAf-dCSz_cqMlekl3xyobnGMDufV1K9R59V0iFb7WcWRRKl1dxHy4Ybuab9fAcPHCNyDwCb4MXgsHY73eBItSVxyphQIzBx-B6XiMybsLVcSLAJgb1ZHsekUTYf9FbZTteCC8mkimoOoDzVLoMmO5FjnOc2y5NpUpeigBFHWx6wgvGszyg-E5GVdsaIuj4lsKKE5oVlOSVEWWSoEK9uiyoXIqCCsRDmBgUmVKvVzSI3tE-lcgKbKjlWZKNaCctNXjdI29NGP9CW6VDHdR2tYEz0-GbU4J7aJMk9t6B3KiZLOu03YS6-mL-RcXJz3--zAguaAR-YciDiYh3OLl8lK7SSPE9bGL1NOglXN1fvRxeOnF0QvvfTX0KbcDIheYvvl8TRa8wO4R_QybdIhepn2-TsAAP__BUi7oA">