diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-04-10 17:08:25 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-04-10 17:08:25 +0000 |
commit | 42963612a4187b55685b7f75489c11abd3fa100e (patch) | |
tree | 1ff36ac71fba76ce1ed067b988a2b2aa16049837 /test/CXX | |
parent | 5915561b32212af1179a2cabd894f49b4b0dc016 (diff) |
Rework implementation of null non-type template arguments based on
Richard's feedback, to properly catch non-constant expressions and
type mismatches. Finishes <rdar://problem/11193097>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX')
-rw-r--r-- | test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp b/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp index d72f26ecdb..f31c3daf15 100644 --- a/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp +++ b/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp @@ -4,13 +4,15 @@ namespace std { typedef decltype(nullptr) nullptr_t; } -template<int *ip> struct IP { // expected-note 2 {{template parameter is declared here}} +template<int *ip> struct IP { // expected-note 4 {{template parameter is declared here}} IP<ip> *ip2; }; constexpr std::nullptr_t get_nullptr() { return nullptr; } -std::nullptr_t np; +constexpr std::nullptr_t np = nullptr; + +std::nullptr_t nonconst_np; IP<0> ip0; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}} IP<(0)> ip1; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}} @@ -18,6 +20,8 @@ IP<nullptr> ip2; IP<get_nullptr()> ip3; IP<(int*)0> ip4; IP<np> ip5; +IP<nonconst_np> ip5; // expected-error{{non-type template argument for template parameter of pointer type 'int *' must have its address taken}} +IP<(float*)0> ip6; // expected-error{{null non-type template argument of type 'float *' does not match template parameter of type 'int *'}} struct X { }; template<int X::*pm> struct PM { // expected-note 2 {{template parameter is declared here}} |