[all-commits] [llvm/llvm-project] 0e0e8b: Do not evaluate dependent immediate invocations

Utkarsh Saxena via All-commits all-commits at lists.llvm.org
Thu Aug 18 01:31:27 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0e0e8b65765e32776a5188e96d1672baeb11b16c
      https://github.com/llvm/llvm-project/commit/0e0e8b65765e32776a5188e96d1672baeb11b16c
  Author: Utkarsh Saxena <usx at google.com>
  Date:   2022-08-18 (Thu, 18 Aug 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Sema/SemaExpr.cpp
    M clang/test/SemaCXX/cxx2a-consteval.cpp

  Log Message:
  -----------
  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




More information about the All-commits mailing list