Previously, this caused ExprConstant to assert while verifying the lambda is constexpr:
void f() { int x = 0; [=]() constexpr { return x; }; }
The problem is that ActOnFinishFunctionBody evaluated the lambda's body before BuildLambdaExpr finished the lambda class. This patch fixes the problem by moving that check to BuildLambdaExpr.
PR36054
Thanks for taking a look!
Erik
Hmm - as opposed to further leaking our lambda's implementation-details into ActOnFinishFunctionBody - and duplicating these checks for a lambda marked constexpr, I think I would prefer teaching the expression-evaluator (ExprConstant.cpp) to know how to check a lambda's function call operator for constexprness (i.e. avoid creating the capture-to-field-map when 'checkingPotentialConstantExpression()' and ignore evaluating expressions that refer to enclosing variables since their evaluation should not affect inferring constexprness).
Thoughts?