summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/lambda-expressions.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2012-08-08 17:33:31 +0000
committerDavid Blaikie <dblaikie@gmail.com>2012-08-08 17:33:31 +0000
commit1c7c8f763769d7d98b8ef7538693f7d99be3cedd (patch)
treeeae471efe22aa10e1875415c0d68f9b1c0cf57a2 /clang/test/SemaCXX/lambda-expressions.cpp
parenta5063a620847de422e64c330ed5d07718583bf9c (diff)
downloadbcm5719-llvm-1c7c8f763769d7d98b8ef7538693f7d99be3cedd.tar.gz
bcm5719-llvm-1c7c8f763769d7d98b8ef7538693f7d99be3cedd.zip
Implement warning for integral null pointer constants other than the literal 0.
This is effectively a warning for code that violates core issue 903 & thus will become standard error in the future, hopefully. It catches strange null pointers such as: '\0', 1 - 1, const int null = 0; etc... There's currently a flaw in this warning (& the warning for 'false' as a null pointer literal as well) where it doesn't trigger on comparisons (ptr == '\0' for example). Fix to come in a future patch. Also, due to this only being a warning, not an error, it triggers quite frequently on gtest code which tests expressions for null-pointer-ness in a SFINAE context (so it wouldn't be a problem if this was an error as in an actual implementation of core issue 903). To workaround this for now, the diagnostic does not fire in unevaluated contexts. Review by Sean Silva and Richard Smith. llvm-svn: 161501
Diffstat (limited to 'clang/test/SemaCXX/lambda-expressions.cpp')
-rw-r--r--clang/test/SemaCXX/lambda-expressions.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang/test/SemaCXX/lambda-expressions.cpp b/clang/test/SemaCXX/lambda-expressions.cpp
index 198f8cf1fef..0fd634502bc 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -117,16 +117,16 @@ namespace NullPtr {
const int m = 0;
[=] {
- int &k = f(m); // a null pointer constant
+ int &k = f(m); // expected-warning{{expression which evaluates to zero treated as a null pointer constant of type 'int *'}}
} ();
[=] () -> bool {
- int &k = f(m); // a null pointer constant
+ int &k = f(m); // expected-warning{{expression which evaluates to zero treated as a null pointer constant of type 'int *'}}
return &m == 0;
} ();
[m] {
- int &k = f(m); // a null pointer constant
+ int &k = f(m); // expected-warning{{expression which evaluates to zero treated as a null pointer constant of type 'int *'}}
} ();
}
}
OpenPOWER on IntegriCloud