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

    <tr>
        <th>Summary</th>
        <td>
            [C++20] Call to consteval function with arguments dependent on templates does not immediate-escalate properly
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          MitalAshok
      </td>
    </tr>
</table>

<pre>
    First example:

```c++
consteval void f(int) {}

template<typename T>
struct G {
    void g() {
 ::f(T::fn());
 }
};
```

https://godbolt.org/z/qYfs8jzon

```
<source>:6:9: error: cannot take address of consteval function 'f' outside of an immediate invocation
    6 |         ::f(T::fn());
      | ^
<source>:1:16: note: declared here
    1 | consteval void f(int) {}
      |                ^
```

Second example:

```c++
consteval void f(int) {}

template<typename T>
void g() {
    auto l = []{
        ::f(T::fn());
 };
}

struct Y {
    static int fn();
};

template void g<Y>();
```

https://godbolt.org/z/zrsEqPa5s

```
<source>:6:9: error: call to consteval function 'f' is not a constant expression
    6 | ::f(T::fn());
      |         ^
<source>:14:15: note: in instantiation of function template specialization 'g<Y>' requested here
 14 | template void g<Y>();
      |               ^
<source>:6:13: note: non-constexpr function 'fn' cannot be used in a constant expression
    6 |         ::f(T::fn());
      |             ^
<source>:11:16: note: declared here
   11 |     static int fn();
      | ^
```

(`l`'s closure type's call operator should be an immediate lambda since it is an immediate-escalating function containing an immediate-escalating expression, and this should be accepted since it is never called (barring it never producing a constant expression, but that should complain about something else, and not in C++23: [P2448R2](https://wg21.link/P2448R2)))

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVk1zozgQ_TXypSspENjgAwfHHu9pq6Z255KjLLWNJkIiUuNM8uu3BP7AGXvKO3tYihAstfrzvVeIEPTOIlZs-sSmq4noqHa--lOTMItQu5fJxqn3aq19IMAfomkNsmzBkhVLjs9ZMtyS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