Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | 97f1f1c | 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 | |
Richard Smith | 74f0234 | 2017-01-19 21:00:13 +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}} |
| 15 | void f() { |
| 16 | X<float>::X<int> xi = x; // expected-error{{qualified reference to 'X' is a constructor name rather than a template name}} |
| 17 | } |
Douglas Gregor | e362cea | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 18 | |
| 19 | // [temp.local]p1: |
| 20 | |
Douglas Gregor | 0004417 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 21 | // FIXME: test template template parameters |
Douglas Gregor | e362cea | 2009-05-10 22:57:19 +0000 | [diff] [blame] | 22 | template<typename T, typename U> |
| 23 | struct X0 { |
| 24 | typedef T type; |
| 25 | typedef U U_type; |
| 26 | typedef U_type U_type2; |
| 27 | |
| 28 | void f0(const X0&); // expected-note{{here}} |
| 29 | void f0(X0&); |
| 30 | void f0(const X0<T, U>&); // expected-error{{redecl}} |
| 31 | |
| 32 | void f1(const X0&); // expected-note{{here}} |
| 33 | void f1(X0&); |
| 34 | void f1(const X0<type, U_type2>&); // expected-error{{redecl}} |
| 35 | |
| 36 | void f2(const X0&); // expected-note{{here}} |
| 37 | void f2(X0&); |
| 38 | void f2(const ::X0<type, U_type2>&); // expected-error{{redecl}} |
| 39 | }; |
Douglas Gregor | 0004417 | 2009-07-29 16:09:57 +0000 | [diff] [blame] | 40 | |
| 41 | template<typename T, T N> |
| 42 | struct X1 { |
| 43 | void f0(const X1&); // expected-note{{here}} |
| 44 | void f0(X1&); |
| 45 | void f0(const X1<T, N>&); // expected-error{{redecl}} |
| 46 | }; |
| 47 | |
John McCall | e78aac4 | 2010-03-10 03:28:59 +0000 | [diff] [blame] | 48 | namespace pr6326 { |
| 49 | template <class T> class A { |
| 50 | friend class A; |
| 51 | }; |
| 52 | template class A<int>; |
| 53 | } |
Douglas Gregor | 1e13c5a | 2010-04-30 04:39:27 +0000 | [diff] [blame] | 54 | |
| 55 | namespace ForwardDecls { |
| 56 | template<typename T> |
| 57 | struct X; |
| 58 | |
| 59 | template<typename T> |
| 60 | struct X { |
| 61 | typedef T foo; |
| 62 | typedef X<T> xt; |
| 63 | typename xt::foo *t; |
| 64 | }; |
| 65 | } |
Richard Smith | 88fe69c | 2015-07-06 01:45:27 +0000 | [diff] [blame] | 66 | |
| 67 | namespace ConflictingRedecl { |
| 68 | template<typename> struct Nested { |
| 69 | template<typename> struct Nested; // expected-error {{member 'Nested' has the same name as its class}} |
| 70 | }; |
| 71 | } |