1 // RUN: %clang_cc1 -std=c++11 %s -verify -triple x86_64-linux-gnu
4 typedef decltype(nullptr) nullptr_t;
7 template<int *ip> struct IP { // expected-note 5 {{template parameter is declared here}}
11 template<int &ip> struct IR {};
13 constexpr std::nullptr_t get_nullptr() { return nullptr; }
15 constexpr std::nullptr_t np = nullptr;
17 std::nullptr_t nonconst_np; // expected-note{{declared here}}
19 thread_local int tl; // expected-note {{refers here}}
21 IP<0> ip0; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
22 IP<(0)> ip1; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}}
24 IP<get_nullptr()> ip3;
27 IP<nonconst_np> ip5; // expected-error{{non-type template argument of type 'std::nullptr_t' (aka 'nullptr_t') is not a constant expression}} \
28 // expected-note{{read of non-constexpr variable 'nonconst_np' is not allowed in a constant expression}}
29 IP<(float*)0> ip6; // expected-error{{null non-type template argument of type 'float *' does not match template parameter of type 'int *'}}
30 IP<&tl> ip7; // expected-error{{non-type template argument of type 'int *' is not a constant expression}}
32 IR<tl> ir1; // expected-error{{non-type template argument refers to thread-local object}}
35 template<int X::*pm> struct PM { // expected-note 2 {{template parameter is declared here}}
39 PM<0> pm0; // expected-error{{null non-type template argument must be cast to template parameter type 'int X::*'}}
40 PM<(0)> pm1; // expected-error{{null non-type template argument must be cast to template parameter type 'int X::*'}}
42 PM<get_nullptr()> pm3;
46 template<int (X::*pmf)(int)> struct PMF { // expected-note 2 {{template parameter is declared here}}
50 PMF<0> pmf0; // expected-error{{null non-type template argument must be cast to template parameter type 'int (X::*)(int)'}}
51 PMF<(0)> pmf1; // expected-error{{null non-type template argument must be cast to template parameter type 'int (X::*)(int)'}}
53 PMF<get_nullptr()> pmf3;
54 PMF<(int (X::*)(int))0> pmf4;
58 template<std::nullptr_t np> struct NP { // expected-note 2{{template parameter is declared here}}
64 NP<get_nullptr()> np3;
65 NP<0> np4; // expected-error{{null non-type template argument must be cast to template parameter type 'std::nullptr_t' (aka 'nullptr_t')}}
67 NP<i> np5; // expected-error{{non-type template argument of type 'const int' cannot be converted to a value of type 'std::nullptr_t'}}