// 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 template struct X; // expected-note{{template is declared here}} X *x1; X *x2; X<> *x3; // expected-error{{too few template arguments for class template 'X'}} template struct X; X<> *x4; template struct Z { }; template struct Z<>; // PR4362 template struct a { }; template<> struct a { static const bool v = true; }; template::v> struct p { }; // expected-error {{no member named 'v'}} template struct p; // expected-note {{in instantiation of default argument for 'p' required here}} template struct p; // PR5187 template struct A; template struct A; template struct A { void f(A); }; template struct B { }; template<> struct B { typedef B type; }; // Nested default arguments for template parameters. template struct X1 { }; template struct X2 { template::type> // expected-error{{no type named 'type' in 'X1'}} \ // expected-error{{no type named 'type' in 'X1'}} struct Inner1 { }; // expected-note{{template is declared here}} template::value> // expected-error{{no member named 'value' in 'X1'}} \ // expected-error{{no member named 'value' in 'X1'}} struct NonType1 { }; // expected-note{{template is declared here}} template struct Inner2 { }; template struct Inner3 { template struct VeryInner { }; template struct NonType2 { }; }; }; X2 x2i; // expected-note{{in instantiation of template class 'X2' requested here}} X2::Inner1 x2iif; X2::Inner1<> x2bad; // expected-error{{too few template arguments for class template 'Inner1'}} X2::NonType1<'a'> x2_nontype1; X2::NonType1<> x2_nontype1_bad; // expected-error{{too few template arguments for class template 'NonType1'}} // Check multi-level substitution into template type arguments X2::Inner3::VeryInner<> vi; X2::Inner3::NonType2<> x2_deep_nontype; // expected-note{{in instantiation of template class 'X2' requested here}} template struct is_same { static const bool value = false; }; template struct is_same { static const bool value = true; }; int array1[is_same<__typeof__(vi), X2::Inner3::VeryInner >::value? 1 : -1]; int array2[is_same<__typeof(x2_deep_nontype), X2::Inner3::NonType2 >::value? 1 : -1]; // Template template parameter defaults template class X = X2> struct X3 { }; int array3[is_same, X3 >::value? 1 : -1]; struct add_pointer { template struct apply { typedef T* type; }; }; template class X = T::template apply> struct X4; int array4[is_same, X4 >::value? 1 : -1]; template struct X5 {}; // expected-note{{has a different type 'int'}} template struct X5b {}; template class B = X5> // expected-error{{template template argument has different}} \ // expected-note{{previous non-type template parameter}} struct X6 {}; X6 x6a; X6 x6b; // expected-note{{while checking a default template argument}} X6 x6c; template class X = B > struct X7; // expected-error{{must be a class template}} namespace PR9643 { template class allocator {}; template > class vector {}; template > class container, typename DT> container
initializer(const DT& d) { return container
(); } void f() { vector > v = initializer(5); } } namespace PR16288 { template struct S { template #if __cplusplus <= 199711L // C++03 or earlier modes // expected-warning@-2 {{default template arguments for a function template are a C++11 extension}} #endif void f(); }; template template void S::f() {} } namespace DR1635 { template struct X { template static void f(int) {} // expected-error {{type 'int' cannot be used prior to '::' because it has no members}} #if __cplusplus <= 199711L // C++03 or earlier modes // expected-warning@-2 {{default template arguments for a function template are a C++11 extension}} #endif static void f(...) {} }; int g() { X::f(0); } // expected-note {{in instantiation of template class 'DR1635::X' requested here}} } namespace NondefDecls { template void f1() { int g1(int defarg = T::error); // expected-error{{type 'int' cannot be used prior to '::' because it has no members}} } template void f1(); // expected-note{{in instantiation of function template specialization 'NondefDecls::f1' requested here}} } template struct C { C(T t = ); // expected-error {{expected expression}} }; C obj; namespace PR26134 { // Make sure when substituting default template arguments we do it in the current context. template struct X {}; template struct Y { void f() { X xy; } static const bool value = B; }; namespace ns1 { template struct X { template struct XInner { static const bool value = B; }; }; template struct S { static const bool value = B; }; #if __cplusplus > 199711L template struct Y { static constexpr bool f() { return typename X>::template XInner<>{}.value; } static_assert(f() == B, ""); }; Y y; Y y2; #endif } // end ns1 } // end ns PR26134