diff options
| author | David Blaikie <dblaikie@gmail.com> | 2012-08-08 17:33:31 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2012-08-08 17:33:31 +0000 |
| commit | 1c7c8f763769d7d98b8ef7538693f7d99be3cedd (patch) | |
| tree | eae471efe22aa10e1875415c0d68f9b1c0cf57a2 /clang/test/SemaTemplate/explicit-instantiation.cpp | |
| parent | a5063a620847de422e64c330ed5d07718583bf9c (diff) | |
| download | bcm5719-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/SemaTemplate/explicit-instantiation.cpp')
| -rw-r--r-- | clang/test/SemaTemplate/explicit-instantiation.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/test/SemaTemplate/explicit-instantiation.cpp b/clang/test/SemaTemplate/explicit-instantiation.cpp index 13d76befe28..e3e77d08284 100644 --- a/clang/test/SemaTemplate/explicit-instantiation.cpp +++ b/clang/test/SemaTemplate/explicit-instantiation.cpp @@ -14,7 +14,7 @@ struct X0 { T f0(T x) { return x + 1; // expected-error{{invalid operands}} } - T* f0(T*, T*) { return T(); } + T* f0(T*, T*) { return T(); } // expected-warning{{expression which evaluates to zero treated as a null pointer constant of type 'int *'}} template<typename U> T f0(T, U) { return T(); } @@ -32,7 +32,7 @@ struct NotDefaultConstructible { // expected-note{{candidate constructor (the im template NotDefaultConstructible X0<NotDefaultConstructible>::value; // expected-note{{instantiation}} template int X0<int>::f0(int); -template int* X0<int>::f0(int*, int*); +template int* X0<int>::f0(int*, int*); // expected-note{{in instantiation of member function 'X0<int>::f0' requested here}} template int X0<int>::f0(int, float); template int X0<int>::f0(int) const; // expected-error{{does not refer}} |

