Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | befc20e | 2009-03-26 00:10:35 +0000 | [diff] [blame] | 2 | template<typename T> |
| 3 | struct X { |
| 4 | X<T*> *ptr; |
| 5 | }; |
| 6 | |
| 7 | X<int> x; |
| 8 | |
| 9 | template<> |
| 10 | struct X<int***> { |
| 11 | typedef X<int***> *ptr; |
| 12 | }; |
| 13 | |
Douglas Gregor | 0efc2c1 | 2010-01-13 17:31:36 +0000 | [diff] [blame] | 14 | X<float>::X<int> xi = x; // expected-error{{qualified reference to 'X' is a constructor name rather than a template name wherever a constructor can be declared}} |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 15 | |
| 16 | // [temp.local]p1: |
| 17 | |
Douglas Gregor | 828e226 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 18 | // FIXME: test template template parameters |
Douglas Gregor | 7da97d0 | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 19 | template<typename T, typename U> |
| 20 | struct X0 { |
| 21 | typedef T type; |
| 22 | typedef U U_type; |
| 23 | typedef U_type U_type2; |
| 24 | |
| 25 | void f0(const X0&); // expected-note{{here}} |
| 26 | void f0(X0&); |
| 27 | void f0(const X0<T, U>&); // expected-error{{redecl}} |
| 28 | |
| 29 | void f1(const X0&); // expected-note{{here}} |
| 30 | void f1(X0&); |
| 31 | void f1(const X0<type, U_type2>&); // expected-error{{redecl}} |
| 32 | |
| 33 | void f2(const X0&); // expected-note{{here}} |
| 34 | void f2(X0&); |
| 35 | void f2(const ::X0<type, U_type2>&); // expected-error{{redecl}} |
| 36 | }; |
Douglas Gregor | 828e226 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 37 | |
| 38 | template<typename T, T N> |
| 39 | struct X1 { |
| 40 | void f0(const X1&); // expected-note{{here}} |
| 41 | void f0(X1&); |
| 42 | void f0(const X1<T, N>&); // expected-error{{redecl}} |
| 43 | }; |
| 44 | |
John McCall | 3cb0ebd | 2010-03-10 03:28:59 +0000 | [diff] [blame] | 45 | namespace pr6326 { |
| 46 | template <class T> class A { |
| 47 | friend class A; |
| 48 | }; |
| 49 | template class A<int>; |
| 50 | } |
Douglas Gregor | 9ffce21 | 2010-04-30 04:39:27 +0000 | [diff] [blame] | 51 | |
| 52 | namespace ForwardDecls { |
| 53 | template<typename T> |
| 54 | struct X; |
| 55 | |
| 56 | template<typename T> |
| 57 | struct X { |
| 58 | typedef T foo; |
| 59 | typedef X<T> xt; |
| 60 | typename xt::foo *t; |
| 61 | }; |
| 62 | } |