diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaCXX/member-pointer.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaTemplate/instantiate-complete.cpp | 8 | ||||
-rw-r--r-- | clang/test/SemaTemplate/instantiate-typedef.cpp | 3 | ||||
-rw-r--r-- | clang/test/SemaTemplate/temp_explicit.cpp | 38 |
4 files changed, 46 insertions, 7 deletions
diff --git a/clang/test/SemaCXX/member-pointer.cpp b/clang/test/SemaCXX/member-pointer.cpp index 1a663f6e1cc..cfe4f75dd17 100644 --- a/clang/test/SemaCXX/member-pointer.cpp +++ b/clang/test/SemaCXX/member-pointer.cpp @@ -80,7 +80,7 @@ void g() { void (HasMembers::*pmd)() = &HasMembers::d; } -struct Incomplete; // expected-note{{forward declaration}} +struct Incomplete; void h() { HasMembers hm, *phm = &hm; @@ -115,7 +115,7 @@ void h() { Incomplete *inc; int Incomplete::*pii = 0; - (void)inc->*pii; // expected-error {{right hand operand is a pointer to member of incomplete type 'struct Incomplete'}} + (void)(inc->*pii); // okay } struct OverloadsPtrMem diff --git a/clang/test/SemaTemplate/instantiate-complete.cpp b/clang/test/SemaTemplate/instantiate-complete.cpp index 7b4373538d2..babc55217a9 100644 --- a/clang/test/SemaTemplate/instantiate-complete.cpp +++ b/clang/test/SemaTemplate/instantiate-complete.cpp @@ -11,8 +11,7 @@ struct X { // expected-error{{data member instantiated with function type 'int (int)'}} \ // expected-error{{data member instantiated with function type 'char (char)'}} \ // expected-error{{data member instantiated with function type 'short (short)'}} \ - // expected-error{{data member instantiated with function type 'float (float)'}} \ - // expected-error{{data member instantiated with function type 'long (long)'}} + // expected-error{{data member instantiated with function type 'float (float)'}} }; X<int> f() { return 0; } @@ -41,7 +40,8 @@ void test_new() { } void test_memptr(X<long> *p1, long X<long>::*pm1, - X<long(long)> *p2, long (X<long(long)>::*pm2)(long)) { + X<long(long)> *p2, + long (X<long(long)>::*pm2)(long)) { (void)(p1->*pm1); - (void)(p2->*pm2); // expected-note{{in instantiation of template class 'struct X<long (long)>' requested here}} + (void)((p2->*pm2)(0)); } diff --git a/clang/test/SemaTemplate/instantiate-typedef.cpp b/clang/test/SemaTemplate/instantiate-typedef.cpp index c1355fca8d5..d30309cc86c 100644 --- a/clang/test/SemaTemplate/instantiate-typedef.cpp +++ b/clang/test/SemaTemplate/instantiate-typedef.cpp @@ -11,5 +11,6 @@ add_pointer<float>::type test2(int * ptr) { return ptr; // expected-error{{incompatible type returning 'int *', expected 'add_pointer<float>::type' (aka 'float *')}} } -add_pointer<int&>::type // expected-note{{in instantiation of template class 'struct add_pointer<int &>' requested here}} expected-error {{unknown type name 'type'}} +add_pointer<int&>::type // expected-note{{in instantiation of template class 'struct add_pointer<int &>' requested here}} \ +// expected-error {{unknown type name 'type'}} test3(); diff --git a/clang/test/SemaTemplate/temp_explicit.cpp b/clang/test/SemaTemplate/temp_explicit.cpp index 0b96c73c1f2..6394f1daf47 100644 --- a/clang/test/SemaTemplate/temp_explicit.cpp +++ b/clang/test/SemaTemplate/temp_explicit.cpp @@ -71,3 +71,41 @@ void f3(X4<int&>::Inner); // okay, Inner::VeryInner, not instantiated template struct X4<int&>; // expected-note{{instantiation}} template struct X4<float&>; // expected-note{{instantiation}} + +// Check explicit instantiation of member classes +namespace N2 { + +template<typename T> +struct X5 { + struct Inner1 { + void f(T&); + }; + + struct Inner2 { + struct VeryInner { // expected-note 2{{instantiation}} + void g(T*); // expected-error 2{{pointer to a reference}} + }; + }; +}; + +} + +template struct N2::X5<void>::Inner2; + +using namespace N2; +template struct X5<int&>::Inner2; // expected-note{{instantiation}} + +void f4(X5<float&>::Inner2); +template struct X5<float&>::Inner2; // expected-note{{instantiation}} + +namespace N3 { + template struct N2::X5<int>::Inner2; +} + +struct X6 { + struct Inner { // expected-note{{here}} + void f(); + }; +}; + +template struct X6::Inner; // expected-error{{non-templated}} |