diff options
author | dim <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-04-14 14:01:31 +0000 |
commit | 50b73317314e889cf39c7b1d6cbf419fa7502f22 (patch) | |
tree | be1815eb79b42ff482a8562b13c2dcbf0c5dcbee /test/SemaCXX/nullptr.cpp | |
parent | dc04cb328508e61aad809d9b53b12f9799a00e7d (diff) | |
download | FreeBSD-src-50b73317314e889cf39c7b1d6cbf419fa7502f22.zip FreeBSD-src-50b73317314e889cf39c7b1d6cbf419fa7502f22.tar.gz |
Vendor import of clang trunk r154661:
http://llvm.org/svn/llvm-project/cfe/trunk@r154661
Diffstat (limited to 'test/SemaCXX/nullptr.cpp')
-rw-r--r-- | test/SemaCXX/nullptr.cpp | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/test/SemaCXX/nullptr.cpp b/test/SemaCXX/nullptr.cpp index 6f66036..e313603 100644 --- a/test/SemaCXX/nullptr.cpp +++ b/test/SemaCXX/nullptr.cpp @@ -109,19 +109,30 @@ namespace test3 { } } -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 +static_assert(__is_scalar(nullptr_t), ""); +static_assert(__is_pod(nullptr_t), ""); +static_assert(sizeof(nullptr_t) == sizeof(void*), ""); + +static_assert(!(nullptr < nullptr), ""); +static_assert(!(nullptr > nullptr), ""); +static_assert( nullptr <= nullptr, ""); +static_assert( nullptr >= nullptr, ""); +static_assert( nullptr == nullptr, ""); +static_assert(!(nullptr != nullptr), ""); + +static_assert(!(0 < nullptr), ""); +static_assert(!(0 > nullptr), ""); +static_assert( 0 <= nullptr, ""); +static_assert( 0 >= nullptr, ""); +static_assert( 0 == nullptr, ""); +static_assert(!(0 != nullptr), ""); + +static_assert(!(nullptr < 0), ""); +static_assert(!(nullptr > 0), ""); +static_assert( nullptr <= 0, ""); +static_assert( nullptr >= 0, ""); +static_assert( nullptr == 0, ""); +static_assert(!(nullptr != 0), ""); namespace overloading { int &f1(int*); @@ -161,3 +172,14 @@ namespace templates { X2<nullptr, nullptr, nullptr, nullptr> x2; } + +namespace null_pointer_constant { + +// Pending implementation of core issue 903, ensure we don't allow any of the +// C++11 constant evaluation semantics in null pointer constants. +struct S { int n; }; +constexpr int null() { return 0; } +void *p = S().n; // expected-error {{cannot initialize}} +void *q = null(); // expected-error {{cannot initialize}} + +} |