<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/123524>123524</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang++] if-contexpr expression aren't parsed in an immediate function context
</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>
Sorry for all of these similar bugs! Just filing for now to document; I may have time to help with some PRs in a few weeks.
https://godbolt.org/z/5ejE5f1vK
The "condition of a constexpr if statement" is one of the forms that constitute a manifestly constant-evaluated expression. Since subexpressions of manifestly constant-evaluated expressions are considered to be within an _immediate function context_, the immediate-escalating expression `&fn` should be valid and allowed.
We might consider pushing an `ExpressionEvaluationContext` [here](https://github.com/llvm/llvm-project/blob/main/clang/lib/Parse/ParseExprCXX.cpp#L2207) when `CK == ConditionKind::ConstexprIf`, just prior to calling `ParseExpression()`.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUU19r4zgQ_zTjl6HBHkfJ-sEPbVLDXu9huT24fVtkaRyrK0tGkpNtP_0hJ22Pg4NbMAjk0czv38gYzckxtyAeQBwLuaTRh_aHTK96KnqvX9qvPoQXHHxAaS36AdPIkTGayVgZsF9OEajC35aYcDDWuNNa7PwFk0ft1TKxS1A_4Gec5AuO8syYzMT598h2xotJI0Y_MX75I6JxKHHgC16Yf8QNlPdQ3o8pzRHqe6AOqDt53XubNj6cgLpXoE7w86MYqvPTtfzPkRGIlHfaJONdhi1ReRcT_5wDmgFjkolXZERoInrHN3IZ_hQxjTJdn5i0JEaJk3Rm4Jjsy_VeunTHZ2kXmVhjbswxGu82-NU4xRiX_uMy5u7_t0NEGXgtMZoD6yxVz6tQWR6H3800sTYyMQ6LUytH5V3in-k70GGl8V5yx1FJK1O25mMGwq4E2g0OdiXG0S9W5xlnaY1G6XS2219Y3xz4i3EypzG9o8J5iWNuKddWj--NH6-EjHeHK6I8AMTDyIFBHIE-_ctNk8al3yg_AXXWnt-Ouzn4Z1YJqOut74G6SRoH1CkrXTbemnz5RYbIb2dGcfj2baPmGaj-najcAzV4GXkFeXhCqI9QH_HwFo0n43SGUt8f3uLxeVilOeBzzvQcjA_ZACXtmm7Yle-zroyBPgE1sCs3hW5r3dSNLLit9vW-rna03xdjW_X1dquaXpFgJaipJetabBVTI4TgsjAtlSTKqmqqRlTVfqP3lazL7bYeVCU072Bb8iSN3WRtcvQLE-PCbUW1oG1hZc82rntMdFOI8kqHdhVz3dNtaU1M8aNFMsmuy3978ZA_cUQz3F3jNId_RkYGdkD7hHMWQOM1jP-dxWIJtv1lt1deEai7UTu39HcAAAD__xWhkpw">