diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2014-09-15 16:45:40 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2014-09-15 17:38:42 +0200 |
commit | e823a9bd63ad4c6bf86dd2b794d34ab6920a83c4 (patch) | |
tree | ad9e65a1fbe2137ceac0ef9c44fff25a3d51c610 /compilerplugins | |
parent | aa2444c6b130f89d0835ddc966ba639ad4caa6ff (diff) |
do not warn about "null pointer conversions" from integers in C++98 mode
Change-Id: I15c7f52c542549ad131400c9b5395a06a4777687
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/literaltoboolconversion.cxx | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/compilerplugins/clang/literaltoboolconversion.cxx b/compilerplugins/clang/literaltoboolconversion.cxx index 4c3c3a4cee8f..b84500a595b3 100644 --- a/compilerplugins/clang/literaltoboolconversion.cxx +++ b/compilerplugins/clang/literaltoboolconversion.cxx @@ -116,18 +116,15 @@ bool LiteralToBoolConversion::VisitImplicitCastExpr( << expr->getCastKindName() << expr->getSubExpr()->getType() << expr->getType() << expr->getSourceRange(); } -// At least Clang 3.2 would erroneously warn about Cache::add -// (binaryurp/source/cache.hxx:53) -// -// if( !size_) { -// -// as "implicit conversion (IntegralToBoolean) of null pointer constant of type -// 'std::size_t' (aka 'unsigned long') to 'bool'": -#if (__clang_major__ == 3 && __clang_minor__ >= 4) || __clang_major__ > 3 } else if (sub->isNullPointerConstant( compiler.getASTContext(), Expr::NPC_ValueDependentIsNull) - != Expr::NPCK_NotNull) + > Expr::NPCK_ZeroExpression) { + // The test above originally checked for != Expr::NPCK_NotNull, but in non-C++11 + // mode we can get also Expr::NPCK_ZeroExpression inside templates, even though + // the expression is actually not a null pointer. Clang bug or C++98 misfeature? + // See Clang's NPCK_ZeroExpression declaration and beginning of isNullPointerConstant(). + static_assert( Expr::NPCK_NotNull == 0 && Expr::NPCK_ZeroExpression == 1, "Clang API change" ); report( DiagnosticsEngine::Warning, ("implicit conversion (%0) of null pointer constant of type %1 to" @@ -135,7 +132,6 @@ bool LiteralToBoolConversion::VisitImplicitCastExpr( expr->getLocStart()) << expr->getCastKindName() << expr->getSubExpr()->getType() << expr->getType() << expr->getSourceRange(); -#endif } else if (sub->isIntegerConstantExpr(res, compiler.getASTContext())) { report( DiagnosticsEngine::Warning, |