1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -ffreestanding %s
4 typedef decltype(nullptr) nullptr_t
;
10 void o2(char*); // expected-note {{candidate}}
11 void o2(int A::*); // expected-note {{candidate}}
13 nullptr_t
f(nullptr_t null
)
15 // Implicit conversions.
24 void (*pf
)() = nullptr;
26 void (A::*pmf
)() = nullptr;
30 // Can't convert nullptr to integral implicitly.
31 uintptr_t i
= nullptr; // expected-error {{cannot initialize}}
34 (void)(null
== nullptr);
35 (void)(null
<= nullptr);
36 (void)(null
== (void*)0);
37 (void)((void*)0 == nullptr);
38 (void)(null
<= (void*)0);
39 (void)((void*)0 <= nullptr);
44 (void)(1 > nullptr); // expected-error {{invalid operands to binary expression}}
45 (void)(1 != nullptr); // expected-error {{invalid operands to binary expression}}
46 (void)(1 + nullptr); // expected-error {{invalid operands to binary expression}}
47 (void)(0 ? nullptr : 0); // expected-error {{incompatible operand types}}
48 (void)(0 ? nullptr : (void*)0);
53 o2(nullptr); // expected-error {{ambiguous}}
55 // nullptr is an rvalue, null is an lvalue
56 (void)&nullptr; // expected-error {{address expression must be an lvalue}}
57 nullptr_t
*pn
= &null
;
59 // You can reinterpret_cast nullptr to an integer.
60 (void)reinterpret_cast<uintptr_t>(nullptr);
62 // You can throw nullptr.
66 // Template arguments can be nullptr.
67 template <int *PI
, void (*PF
)(), int A::*PM
, void (A::*PMF
)()>
70 typedef T
<nullptr, nullptr, nullptr, nullptr> NT
;
73 template<typename T
, typename U
> struct is_same
{
74 static const bool value
= false;
77 template<typename T
> struct is_same
<T
, T
> {
78 static const bool value
= true;
84 // Test that we prefer g(void*) over g(bool).
85 static_assert(is_same
<decltype(g(nullptr)), void*>::value
, "");
89 void f(int, ...) __attribute__((sentinel
));
92 // nullptr can be used as the sentinel value.
98 void f(const char*, ...) __attribute__((format(printf
, 1, 2)));
101 // Don't warn when using nullptr with %p.