Do not evaluate dependent immediate invocations
authorUtkarsh Saxena <usx@google.com>
Wed, 17 Aug 2022 14:44:41 +0000 (16:44 +0200)
committerUtkarsh Saxena <usx@google.com>
Thu, 18 Aug 2022 08:30:40 +0000 (10:30 +0200)
commit0e0e8b65765e32776a5188e96d1672baeb11b16c
treee4262083453defc4903112a9ea08e9f24e3740f1
parente9c5bde88ea2e35fadb15c5e5a1d2cb583fd0772
Do not evaluate dependent immediate invocations

We deferred the evaluation of dependent immediate invocations in https://reviews.llvm.org/D119375 until instantiation.
We should also not consider them referenced from a non-consteval context.

Fixes: https://github.com/llvm/llvm-project/issues/55601

```
template<typename T>
class Bar {
  consteval static T x() { return 5; }
 public:
  Bar() : a(x()) {}

 private:
  int a;
};

Bar<int> g();
```
Is now accepted by clang. Previously it errored with: `cannot take address of consteval function 'x' outside of an immediate invocation  Bar() : a(x()) {}`

Differential Revision: https://reviews.llvm.org/D132031
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/cxx2a-consteval.cpp