[PATCH] D113859: [Sema] Fix consteval function calls with value-dependent args
Léo Lam via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 14 17:17:17 PST 2021
leoetlino added a comment.
While this patch doesn't introduce new regressions and does fix compilation of the code snippet mentioned earlier, I'm not sure this is the correct approach, considering there are a bunch of other similar template-related consteval bugs that this patch does *not* fix:
template <typename T>
struct Foo {
static consteval void ok(int) {}
static consteval void bad(T) {}
template <typename U>
static consteval void call(T x, U fn) { fn(x); }
static constexpr bool test() {
ok({});
bad({}); // error: cannot take address of consteval function 'bad' outside of an immediate invocation
call({}, bad); // error: cannot take address of consteval function 'bad' outside of an immediate invocation
return true;
}
};
The problem seems to be that the call/arguments are type dependent so nothing is added to `ImmediateInvocationCandidates` -- and so `HandleImmediateInvocations` (in SemaExpr.cpp) never removes anything from `ReferenceToConsteval` despite the references to the consteval functions being used for immediate invocations.
Another variant of the issue:
template <typename T>
struct Bar {
static consteval void bad(int) {}
static constexpr bool test() {
bad(T::value); // error: cannot take address of consteval function 'bad' outside of an immediate invocation
return true;
}
};
Not sure what the best way of fixing those issues would be -- any guidance would be greatly appreciated!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113859/new/
https://reviews.llvm.org/D113859
More information about the cfe-commits
mailing list