diff options
author | dim <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
commit | c49018d9cce52d8c9f34b44865ec3ba8e89a1488 (patch) | |
tree | c5e9e10bc189de0058aa763c47b9920a8351b7df /test/SemaCXX/nullptr.cpp | |
parent | 110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab (diff) | |
download | FreeBSD-src-c49018d9cce52d8c9f34b44865ec3ba8e89a1488.zip FreeBSD-src-c49018d9cce52d8c9f34b44865ec3ba8e89a1488.tar.gz |
Vendor import of clang trunk r132879:
http://llvm.org/svn/llvm-project/cfe/trunk@132879
Diffstat (limited to 'test/SemaCXX/nullptr.cpp')
-rw-r--r-- | test/SemaCXX/nullptr.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/SemaCXX/nullptr.cpp b/test/SemaCXX/nullptr.cpp index 84c80aa..d69af58 100644 --- a/test/SemaCXX/nullptr.cpp +++ b/test/SemaCXX/nullptr.cpp @@ -60,6 +60,10 @@ nullptr_t f(nullptr_t null) // You can reinterpret_cast nullptr to an integer. (void)reinterpret_cast<uintptr_t>(nullptr); + (void)reinterpret_cast<uintptr_t>(*pn); + + int *ip = *pn; + if (*pn) { } // You can throw nullptr. throw nullptr; @@ -104,3 +108,56 @@ namespace test3 { f("%p", nullptr); } } + +int array0[__is_scalar(nullptr_t)? 1 : -1]; +int array1[__is_pod(nullptr_t)? 1 : -1]; +int array2[sizeof(nullptr_t) == sizeof(void*)? 1 : -1]; + +// FIXME: when we implement constexpr, this will be testable. +#if 0 +int relational0[nullptr < nullptr? -1 : 1]; +int relational1[nullptr > nullptr? -1 : 1]; +int relational2[nullptr <= nullptr? 1 : -1]; +int relational3[nullptr >= nullptr? 1 : -1]; +int equality[nullptr == nullptr? 1 : -1]; +int inequality[nullptr != nullptr? -1 : 1]; +#endif + +namespace overloading { + int &f1(int*); + float &f1(bool); + + void test_f1() { + int &ir = (f1)(nullptr); + } + + struct ConvertsToNullPtr { + operator nullptr_t() const; + }; + + void test_conversion(ConvertsToNullPtr ctn) { + (void)(ctn == ctn); + (void)(ctn != ctn); + (void)(ctn <= ctn); + (void)(ctn >= ctn); + (void)(ctn < ctn); + (void)(ctn > ctn); + } +} + +namespace templates { + template<typename T, nullptr_t Value> + struct X { + X() { ptr = Value; } + + T *ptr; + }; + + X<int, nullptr> x; + + + template<int (*fp)(int), int* p, int A::* pmd, int (A::*pmf)(int)> + struct X2 {}; + + X2<nullptr, nullptr, nullptr, nullptr> x2; +} |