<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/66849>66849</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Clang fails to escalate a plain `constexpr` function to an immediate function in some cases
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          frederick-vs-ja
      </td>
    </tr>
</table>

<pre>
    The following code snippets are rejected by Clang, while they're accepted if `constexpr` is manually replaced with `consteval` ([demo 1](https://godbolt.org/z/den69Ej5a), [demo 2](https://godbolt.org/z/x1jMbhKo1)).

```C++
consteval int next(int n)
{
    return n + 1;
}

constexpr bool test()
{
 int x = 42;
    int y = next(x);
    (void) y;
    return true;
}

static_assert(test());
```

```C++
consteval int *new_ints(unsigned int n)
{
    return new int[n];
}

consteval void delete_ints(int* p)
{
    delete[] p;
}

constexpr bool new_and_delete() // compiles if `constexpr` is manually replaced with `consteval`
{
    auto p = new_ints(42);
 delete_ints(p);
    return true;
}

static_assert(new_and_delete());
```

IIUC `next(x)`, `new_ints(42)` and `delete_ints(p)` are immediate-escalating expressions, and the outer functions `test` and `new_and_delete` are immediate-escalating functions, so the outer functions should be escalated to immediate functions and the examples (along with the original example in #66324) should be well-formed.

CC @cor3ntin.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVV2P8jYT_TXOzQgUHBKSi1ws8CI9etW79nrl2APx1rEj21mgv76aED4W0afbVop2UWbmnJmTY48IQR8sYs3yNcu3iRhi63y996jQa_n77DPMPkTSOHWuf20R9s4Yd9T2ANIphGB132MMIDyCxw-UERU0Z9gYYQ-Mb-DYaoMQWzwzvvIIQkrsKUnvgRWpdDZEPPWeFSnoAJ2wgzDmDB57IyQqOOrY3jM_haFMxkuWrxV2DhYs3zJetjH2gWVvjO8Y3x2capyJc-cPjO_-YHyn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