Skip to content

Commit

Permalink
Do not evaluate dependent immediate invocations
Browse files Browse the repository at this point in the history
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: llvm/llvm-project#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

---

Fixes root-project#13698, a problem
with the new C++ headers from the new macOS SDK.
  • Loading branch information
usx95 authored and dpiparo committed Sep 21, 2023
1 parent f54c828 commit 6627da7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion interpreter/llvm-project/clang/lib/Sema/SemaExpr.cpp
Expand Up @@ -18763,7 +18763,7 @@ void Sema::MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base) {

if (auto *FD = dyn_cast<FunctionDecl>(E->getDecl()))
if (!isConstantEvaluated() && FD->isConsteval() &&
!RebuildingImmediateInvocation)
!RebuildingImmediateInvocation && !FD->isDependentContext())
ExprEvalContexts.back().ReferenceToConsteval.insert(E);
MarkExprReferenced(*this, E->getLocation(), E->getDecl(), E, OdrUse,
RefsMinusAssignments);
Expand Down
2 changes: 1 addition & 1 deletion interpreter/llvm-project/llvm-project.tag
@@ -1 +1 @@
ROOT-llvm13-20230802-01
ROOT-llvm13-20230921-01

0 comments on commit 6627da7

Please sign in to comment.