If any arguments of a consteval function call are value-dependent,
the call cannot be evaluated until instantiation.
This patch fixes Sema::CheckForImmediateInvocation so we don't attempt
to evaluate consteval function calls too early (before instantiation).
This fixes things like:
consteval int f(int n) { return n; }
template <int M>
constexpr int broken() {
return f(M);
}Without the value-dependency checks, what happens is that the constant
expression evaluation engine is called on the following expression:
ConstantExpr 'int' `-CallExpr 'int' |-ImplicitCastExpr 'int (*)(int)' <FunctionToPointerDecay> | `-DeclRefExpr 'int (int)' lvalue Function 'f' 'int (int)' `-DeclRefExpr 'int' NonTypeTemplateParm 'M' 'int'
which obviously fails when it tries to evaluate M.