diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2014-02-11 17:53:22 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2014-02-11 17:53:22 +0000 |
commit | 77ed8972fa29d8ec2ea14dafec25e5e02c021e37 (patch) | |
tree | b7dba72693590379319fce88674421528030e7e4 | |
parent | f07582499884523cd47414e2fde8fe7dae09f74d (diff) | |
download | bcm5719-llvm-77ed8972fa29d8ec2ea14dafec25e5e02c021e37.tar.gz bcm5719-llvm-77ed8972fa29d8ec2ea14dafec25e5e02c021e37.zip |
[Sema] Revert the change in r200622 that allowed integer casts to silence -Wnon-literal-null-conversion in C code.
It is actually useful to warn in such cases, thanks to Dmitri for pushing on this and making us see the light!
Related to rdar://15925483 and rdar://15922612. The latter radar is where the usefulness of the warning is most clear.
llvm-svn: 201165
-rw-r--r-- | clang/lib/AST/Expr.cpp | 3 | ||||
-rw-r--r-- | clang/test/Sema/warn-null.c | 4 |
2 files changed, 2 insertions, 5 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 649f3580bdd..3f5833c5015 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<ImplicitCastExpr>(this)) { diff --git a/clang/test/Sema/warn-null.c b/clang/test/Sema/warn-null.c index 28ec631415d..3bf2aedc445 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}} } |