diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-21 01:53:02 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-11-21 01:53:02 +0000 |
commit | e934d7c9f5165671f1715ed490c1c66bb8588922 (patch) | |
tree | 3613c2cb2d4bb223bee6802517be30abacab84e1 /clang/lib/Sema/SemaExpr.cpp | |
parent | f22ef5ab1a5bae67c721a5b0478af41fdb18d241 (diff) | |
download | bcm5719-llvm-e934d7c9f5165671f1715ed490c1c66bb8588922.tar.gz bcm5719-llvm-e934d7c9f5165671f1715ed490c1c66bb8588922.zip |
PR10837: Warn if a null pointer constant is formed by a zero integer constant
expression that is not a zero literal, in C. This is a different, and more
targeted, approach than that in r194540.
llvm-svn: 195303
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 26c81ef552c..55f9d6f8a08 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6565,12 +6565,14 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, // C99 6.5.16.1p1: the left operand is a pointer and the right is // a null pointer constant. - if ((LHSType->isPointerType() || - LHSType->isObjCObjectPointerType() || - LHSType->isBlockPointerType()) - && RHS.get()->isNullPointerConstant(Context, - Expr::NPC_ValueDependentIsNull)) { - RHS = ImpCastExprToType(RHS.take(), LHSType, CK_NullToPointer); + if ((LHSType->isPointerType() || LHSType->isObjCObjectPointerType() || + LHSType->isBlockPointerType()) && + RHS.get()->isNullPointerConstant(Context, + Expr::NPC_ValueDependentIsNull)) { + CastKind Kind; + CXXCastPath Path; + CheckPointerConversion(RHS.get(), LHSType, Kind, Path, false); + RHS = ImpCastExprToType(RHS.take(), LHSType, Kind, VK_RValue, &Path); return Compatible; } |