<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/123405>123405</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang++] Functions aren't marked immediate-escalating
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
katzdm
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/rvMWrhhYs
It seems that `PopExpressionEvaluationContext`, which triggers the marking of expressions as immediate-escalating, is performed _after_ the check for whether the function body contains an immediate-escalating expression. Consequently, immediate-escalating functions (i.e., lambdas and constexpr function template specializations) that contain a reference to a consteval function are never marked as immediate.
The RAII object whose teardown invokes `PopExpressionEvaluationContext` is [here](https://github.com/llvm/llvm-project/blob/d6315afff078cb4309b5614562b32520f6e3a2eb/clang/lib/Sema/SemaDecl.cpp#L15992), whereas the call that checks whether the function body contains an immediate-escalating expression is [here](https://github.com/llvm/llvm-project/blob/d6315afff078cb4309b5614562b32520f6e3a2eb/clang/lib/Sema/SemaDecl.cpp#L16006) (a few lines later, but within scope of the RAII guard).
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVE2L5DYQ_TXypVgjyx89PvgwH2sYSCAkgZDTUpLKtjKy5Ehy9-78-iBPz06yDCSHHBYMwkL1XtWrV4UxmtkRDay9Y-1DgXtafBieMD3rtZBefxmWlLbI6lsmRibG2WvpbSp9mJkYn5kYw_nH38Ky_B4Zv2X89jFBJFojpAUTsI7_5LePn7dAMRrvPp7R7piMd_feJfqcWMeZuIfLYtQCKZh5ppBjCVYMT8bN4Cegr_ERMIJZV9IGE32gqNBiMm7OICbCRmHyYSUNn3BKFD4dUGoh9QSTD3BZKC0UjttpdypnArlMUN4lNJnAvUvwtyRKuPcu0p87uWS_HMzvBbziR2DixpRU5pcWV6kxs-hMGVOGfUsl0bpZTARxI2XQmudDrMhE_yLoNU1ACDRRIKcIkge8gp3RvoFhIHB0pnBoSfof2pUv7fp1Ifj59vERvPyDVILL4iNBIgzaXxwYd_ZPFP9TH7P-rL1bKBBrH5i4-cY5Ji27LJVfmRitPb8eH7bgMzUTo7ReMjHqrq5anKaJn26UbGrey7armrYTshat4FNHNQrKT5XF3PvRmvz3C614PR5I2VJtGxP1D1Xb94KJ_sVoFAhfHKbQ2quq2SDx_3HH9ytDx3mXjcTEDcJEF7DGUYTst5C1kXuCi0mLcRCV3yiPXnr1x7xj0Ez0ZaGHWvd1jwUN1ak-VS3val4sA05S9CdseNVgxak6NVSJWtNJTiga2RRmEFy0vKpOomp5zUuUXLeSY614p-WkWcNpRWPLLEheMYWJcaehEnXD28KiJBuPVSXEtWSRt1YYDgXlPkfWcGtiim8QySR77LdrxF3-2gcYv44nBnJMnNLrmLzX4GIP9ttV-O-dPNKPTIzXCs6D-CsAAP__NvTUnQ">