// RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s namespace N { namespace M { template struct Promote; template<> struct Promote { typedef int type; }; template<> struct Promote { typedef int type; }; template<> struct Promote { typedef double type; }; Promote::type *ret_intptr(int* ip) { return ip; } Promote::type *ret_intptr2(int* ip) { return ip; } } M::Promote::type *ret_intptr3(int* ip) { return ip; } M::template Promote::type *ret_intptr4(int* ip) { return ip; } #if __cplusplus <= 199711L // expected-warning@-2 {{'template' keyword outside of a template}} #endif M::template Promote pi; #if __cplusplus <= 199711L // expected-warning@-2 {{'template' keyword outside of a template}} #endif } N::M::Promote::type *ret_intptr5(int* ip) { return ip; } ::N::M::Promote::type *ret_intptr6(int* ip) { return ip; } N::M::template; // expected-error{{expected unqualified-id}} N::M::template Promote; // expected-error{{expected unqualified-id}} namespace N { template struct A; template<> struct A { struct X; }; struct B; } struct ::N::A::X { int foo; }; template struct TestA { typedef typename N::template B::type type; // expected-error{{'B' following the 'template' keyword does not refer to a template}} \ // expected-error{{expected member name}} }; // Reduced from a Boost failure. namespace test1 { template struct pair { T x; T y; static T pair::* const mem_array[2]; }; template T pair::* const pair::mem_array[2] = { &pair::x, &pair::y }; } typedef int T; namespace N1 { template T f0(); } template T N1::f0() { } namespace PR7385 { template< typename > struct has_xxx0 { template< typename > struct has_xxx0_introspect { template< typename > struct has_xxx0_substitute ; template< typename V > int int00( has_xxx0_substitute < typename V::template xxx< > > = 0 ); }; static const int value = has_xxx0_introspect::value; // expected-error{{no member named 'value'}} typedef int type; }; has_xxx0::type t; // expected-note{{instantiation of}} } namespace PR7725 { template struct TypedefProvider; template struct TemplateClass : public TypedefProvider { void PrintSelf() { TemplateClass::Test::PrintSelf(); } }; } namespace PR9226 { template void nt() // expected-note{{function template 'nt' declared here}} { nt<>:: } // expected-error{{qualified name refers into a specialization of function template 'nt'}} \ // expected-error{{expected unqualified-id}} template void f(T*); // expected-note{{function template 'f' declared here}} template void f(T*, T*); // expected-note{{function template 'f' declared here}} void g() { f:: // expected-error{{qualified name refers into a specialization of function template 'f'}} } // expected-error{{expected unqualified-id}} struct X { template void f(); // expected-note{{function template 'f' declared here}} }; template struct Y { typedef typename T::template f type; // expected-error{{template name refers to non-type template 'X::f'}} }; Y yxi; // expected-note{{in instantiation of template class 'PR9226::Y' requested here}} } namespace PR9449 { template struct s; // expected-note{{template is declared here}} template void f() { int s::template n::* f; // expected-error{{implicit instantiation of undefined template 'PR9449::s'}} \ // expected-error{{following the 'template' keyword}} } template void f(); // expected-note{{in instantiation of}} }