1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 template<class T1> 3 class A { 4 template<class T2> class B { 5 void mf(); 6 }; 7 }; 8 9 template<> template<> class A<int>::B<double>; 10 template<> template<> void A<char>::B<char>::mf(); 11 12 template<> void A<char>::B<int>::mf(); // expected-error{{requires 'template<>'}} 13 14 namespace test1 { 15 template <class> class A { 16 static int foo; 17 static int bar; 18 }; 19 typedef A<int> AA; 20 21 template <> int AA::foo = 0; 22 int AA::bar = 1; // expected-error {{template specialization requires 'template<>'}} 23 int A<float>::bar = 2; // expected-error {{template specialization requires 'template<>'}} 24 25 template <> class A<double> { 26 public: 27 static int foo; 28 static int bar; 29 }; 30 31 typedef A<double> AB; 32 template <> int AB::foo = 0; // expected-error{{extraneous 'template<>'}} 33 int AB::bar = 1; 34 } 35 36 namespace GH54151 { 37 38 struct S { 39 int i<0>; // expected-error {{member 'i' cannot have template arguments}} 40 int j<int>; // expected-error {{member 'j' cannot have template arguments}} 41 42 static int k<12>; // expected-error {{template specialization requires 'template<>'}} \ 43 expected-error {{no variable template matches specialization}} \ 44 expected-warning {{explicit specialization cannot have a storage class}} 45 void f<12>(); // expected-error {{template specialization requires 'template<>'}} \ 46 // expected-error {{no function template matches function template specialization 'f'}} 47 }; 48 49 template <typename T, int N> 50 struct U { 51 int i<N>; // expected-error {{member 'i' cannot have template arguments}} 52 int j<T>; // expected-error {{member 'j' cannot have template arguments}} 53 }; 54 55 } // namespace GH54151 56