summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2014-02-26 02:36:06 +0000
committerRichard Trieu <rtrieu@google.com>2014-02-26 02:36:06 +0000
commit3bb8b56a5d90c535e7dc466f924d00ce798c28e0 (patch)
tree643e7740ab5e1fb92239f642327a28a9052c8490 /clang/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp
parentf9be75f538f4712acf98cde444e1176ce775b806 (diff)
downloadbcm5719-llvm-3bb8b56a5d90c535e7dc466f924d00ce798c28e0.tar.gz
bcm5719-llvm-3bb8b56a5d90c535e7dc466f924d00ce798c28e0.zip
PR16074, implement warnings to catch pointer to boolean true and pointer to
null comparison when the pointer is known to be non-null. This catches the array to pointer decay, function to pointer decay and address of variables. This does not catch address of function since this has been previously used to silence a warning. Pointer to bool conversion is under -Wbool-conversion. Pointer to null comparison is under -Wtautological-pointer-compare, a sub-group of -Wtautological-compare. void foo() { int arr[5]; int x; // warn on these conditionals if (foo); if (arr); if (&x); if (foo == null); if (arr == null); if (&x == null); if (&foo); // no warning } llvm-svn: 202216
Diffstat (limited to 'clang/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp')
-rw-r--r--clang/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp b/clang/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp
index 2646264273e..833a4014e86 100644
--- a/clang/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp
+++ b/clang/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp
@@ -15,7 +15,7 @@ bool b4 = !E;
bool b5 = !F;
// -- pointer,
-bool b6 = !&b4;
+bool b6 = !&b4; // expected-warning{{address of 'b4' will always evaluate to 'true'}}
void f();
bool b61 = !&f;
OpenPOWER on IntegriCloud