Don't call isIntegerConstantExpr if isValueDependent

...some paths trough clang::Expr::isIntegerConstantExpr (esp. if
non-CPlusPlus11) assert the assumption that the given expr is not
value-dependent, so it appears to be a prereq

Change-Id: Ibc5fe472ea3f91b31c8cb7f06c4b7c7f4d6831a3
This commit is contained in:
Stephan Bergmann 2014-12-21 22:00:40 +01:00
parent fb7c188842
commit f266c81b2d

View file

@ -47,7 +47,8 @@ bool LiteralToBoolConversion::VisitImplicitCastExpr(
return true;
}
APSInt res;
if (sub->isIntegerConstantExpr(res, compiler.getASTContext())
if (!sub->isValueDependent()
&& sub->isIntegerConstantExpr(res, compiler.getASTContext())
&& res.getLimitedValue() <= 1)
{
SourceLocation loc { sub->getLocStart() };
@ -132,7 +133,9 @@ bool LiteralToBoolConversion::VisitImplicitCastExpr(
expr->getLocStart())
<< expr->getCastKindName() << expr->getSubExpr()->getType()
<< expr->getType() << expr->getSourceRange();
} else if (sub->isIntegerConstantExpr(res, compiler.getASTContext())) {
} else if (!sub->isValueDependent()
&& sub->isIntegerConstantExpr(res, compiler.getASTContext()))
{
report(
DiagnosticsEngine::Warning,
("implicit conversion (%0) of integer constant expression of type"