aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/nullptr.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-08-08 06:13:49 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-08-08 06:13:49 +0000
commit50d61c8ccfc633b13cdf594ea3cd3a217076debe (patch)
treef63370170c819067707d15dba92ee4c14362c712 /test/SemaCXX/nullptr.cpp
parent9a58584bb13d725ecb1ac70ce91c6ac52daa9484 (diff)
Implement final piece of DR963 and also DR587:
A conditional operator between glvalues of types cv1 T and cv2 T produces a glvalue if the expressions are of the same value kind and one of cv1 and cv2 is a subset of the other. A conditional operator between two null pointer constants is permitted if one of them is of type std::nullptr_t. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161476 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/nullptr.cpp')
-rw-r--r--test/SemaCXX/nullptr.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/test/SemaCXX/nullptr.cpp b/test/SemaCXX/nullptr.cpp
index e3136039f4..d148f76698 100644
--- a/test/SemaCXX/nullptr.cpp
+++ b/test/SemaCXX/nullptr.cpp
@@ -33,8 +33,10 @@ nullptr_t f(nullptr_t null)
// Operators
(void)(null == nullptr);
(void)(null <= nullptr);
+ (void)(null == 0);
(void)(null == (void*)0);
(void)((void*)0 == nullptr);
+ (void)(null <= 0);
(void)(null <= (void*)0);
(void)((void*)0 <= nullptr);
(void)(0 == nullptr);
@@ -44,7 +46,7 @@ nullptr_t f(nullptr_t null)
(void)(1 > nullptr); // expected-error {{invalid operands to binary expression}}
(void)(1 != nullptr); // expected-error {{invalid operands to binary expression}}
(void)(1 + nullptr); // expected-error {{invalid operands to binary expression}}
- (void)(0 ? nullptr : 0); // expected-error {{non-pointer operand type 'int' incompatible with nullptr}}
+ (void)(0 ? nullptr : 0);
(void)(0 ? nullptr : (void*)0);
(void)(0 ? nullptr : A()); // expected-error {{non-pointer operand type 'A' incompatible with nullptr}}
(void)(0 ? A() : nullptr); // expected-error {{non-pointer operand type 'A' incompatible with nullptr}}