<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/94147>94147</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] verification of lowering to FIR failed with "internal error when processing function return"
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
Reproducible on Godbolt:
https://godbolt.org/z/3f1h6bW57
Reproducer:
```console
function f(x) result(res)
integer :: i
procedure() :: res
end function
```
With assertion-enabled flang-new, the following assertion failure was observed after "error: verification of lowering to FIR failed":
```txt
llvm-project/flang/include/flang/Lower/StatementContext.h:57: Fortran::lower::StatementContext::~StatementContext(): Assertion `cufs.empty() && "invalid StatementContext destructor call"' failed.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMk8uO2zoMhp9G3ggJbPqWLLzImYEPCnQ1XcxaluhYrSIFFJ3MdNFnL2RnLshsChi-UOTvX59IFaM9esRO1P-J-jFTM0-Bul8bRRSuMRuCee2e8EzBzNoODmXw8v9ghuBYlAeRP4r8MDGfY_qCXkB_XFe3gY4C-t8C-nIspmZ4rts1fb2_iSK964gmXy8dfAwO1-g4e802eDkK2L0I2EvCODsWsCOMAvZrmpRSWs94RJJJsTxI-7FypqDRzIQCdknilpEElhz0Rr796M7MZ9PPliepYkRKiRv0anBo5OiUP248XgU8SJ5QjsG5cLX--JEsR2XdTCivKsowRKQLGqlGTn4BkCgkEvKCZEer1VITRunCFSkpcZD9t6dFBo0A-IqNX3iNOHc5bc4UfqJmAf1iT0BvvXazwU-R70lcQP-DFeMJPT8Ez_jC20mUh7pNfvpATMqvwBYz6-t9yRr98yW88E5Ch3cS6YTnMW7xdObXtwOBRkCTSFh_Uc4aea8kDUamWXMgqZVzCQG0Nx7bOxSZ6UqzL_cqw65oi7bM97uqyKZON6CLsdYl7oxRpimHSu_qBopRF229GzLbQQ5V3uSQN2VeFdtyr40udW1ardqmrEWV40lZt02UU5dnNsYZu31VVG3m1IAuLuMEcMMMabKoW05lmI9RVLmzkeOHAlt2ywz2S0X9-I9tIK-pIRdojOSVk0sfyeuEfu35GFPR-wwR8kxeAGQzue5ucC1P87DV4SSgT9Zuj0-dtOw0CujXzV46-BsAAP__6uRZXg">