diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 649f3580bddc..3f5833c50156 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -3061,9 +3061,6 @@ Expr::isNullPointerConstant(ASTContext &Ctx, Pointee->isVoidType() && // to void* CE->getSubExpr()->getType()->isIntegerType()) // from int. return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC); - // Or an integer cast. - } else if (CE->getType()->isIntegerType()) { - return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC); } } } else if (const ImplicitCastExpr *ICE = dyn_cast(this)) { diff --git a/clang/test/Sema/warn-null.c b/clang/test/Sema/warn-null.c index 28ec631415dd..3bf2aedc445f 100644 --- a/clang/test/Sema/warn-null.c +++ b/clang/test/Sema/warn-null.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 %s -verify -#define NLL (unsigned long long)0 +#define SOME_ADDR (unsigned long long)0 // PR10837: Warn if a non-pointer-typed expression is folded to a null pointer int *p = 0; @@ -10,5 +10,5 @@ void f() { p = 0; q = '\0'; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}} r = 1 - 1; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}} - p = NLL; + p = SOME_ADDR; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}} }