This fixes missing lambda-captures for variables referenced only inside a
static_assert (!), among other things.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304760
91177308-0d34-0410-b5e6-
96231b3b80d8
};
ExprResult ParseExpression(TypeCastState isTypeCast = NotTypeCast);
- ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast);
+ ExprResult ParseConstantExpressionInExprEvalContext(
+ TypeCastState isTypeCast = NotTypeCast);
ExprResult ParseConstantExpression(TypeCastState isTypeCast = NotTypeCast);
ExprResult ParseConstraintExpression();
// Expr that doesn't include commas.
return nullptr;
}
- ExprResult AssertExpr(ParseConstantExpression());
+ EnterExpressionEvaluationContext ConstantEvaluated(
+ Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated);
+ ExprResult AssertExpr(ParseConstantExpressionInExprEvalContext());
if (AssertExpr.isInvalid()) {
SkipMalformedDecl();
return nullptr;
}
}
+ ExprResult FullAssertExpr = ActOnFinishFullExpr(AssertExpr, StaticAssertLoc,
+ /*DiscardedValue*/false,
+ /*IsConstexpr*/true);
+ if (FullAssertExpr.isInvalid())
+ Failed = true;
+ else
+ AssertExpr = FullAssertExpr.get();
+
Decl *Decl = StaticAssertDecl::Create(Context, CurContext, StaticAssertLoc,
AssertExpr, AssertMessage, RParenLoc,
Failed);
}
+
+void PR33318(int i) {
+ [&](auto) { static_assert(&i != nullptr, ""); }(0); // expected-warning 2{{always true}} expected-note {{instantiation}}
+}
template<typename T, T v> struct X {};
template<typename T, T v> void f(X<T, v>) {
- static_assert(!v, "");
+ static_assert(!v, ""); // expected-warning 2{{implicit conversion of nullptr constant to 'bool'}}
}
void g() {
- f(X<int*, nullptr>());
- f(X<nullptr_t, nullptr>());
+ f(X<int*, nullptr>()); // expected-note {{instantiation of}}
+ f(X<nullptr_t, nullptr>()); // expected-note {{instantiation of}}
}
template<template<typename T, T> class X, typename T, typename U, int *P>