aboutsummaryrefslogtreecommitdiff
path: root/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
commit50800fc551ac6b8a95cca662223e7f061bbd169a (patch)
treefd33d7667cfa937b3fa7b4588042e5946f80096d /test/SemaCXX/lambda-expressions.cpp
parented6662dcd95a3349b6c94bb0df2ff4378a029df8 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161501 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/lambda-expressions.cpp')
-rw-r--r--test/SemaCXX/lambda-expressions.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/SemaCXX/lambda-expressions.cpp b/test/SemaCXX/lambda-expressions.cpp
index 198f8cf1fe..0fd634502b 100644
--- a/test/SemaCXX/lambda-expressions.cpp
+++ b/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 *'}}
} ();
}
}