| Daniel Dunbar | 8fbe78f | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s | 
| Douglas Gregor | d522205 | 2009-06-12 19:43:02 +0000 | [diff] [blame] | 2 | template<typename T> struct vector; | 
|  | 3 |  | 
| Douglas Gregor | 30b0197 | 2009-06-12 22:21:45 +0000 | [diff] [blame] | 4 | // C++ [temp.class.spec]p6: | 
|  | 5 | namespace N { | 
|  | 6 | namespace M { | 
|  | 7 | template<typename T> struct A; // expected-note{{here}} | 
|  | 8 | } | 
|  | 9 | } | 
| Douglas Gregor | 8cfd2ba | 2009-06-12 21:21:02 +0000 | [diff] [blame] | 10 |  | 
| Douglas Gregor | 30b0197 | 2009-06-12 22:21:45 +0000 | [diff] [blame] | 11 | template<typename T> | 
| Douglas Gregor | 5488865 | 2009-10-07 00:13:32 +0000 | [diff] [blame] | 12 | struct N::M::A<T*> { }; // expected-error{{originally}} | 
| Douglas Gregor | 30b0197 | 2009-06-12 22:21:45 +0000 | [diff] [blame] | 13 |  | 
|  | 14 | // C++ [temp.class.spec]p9 | 
| Douglas Gregor | 8cfd2ba | 2009-06-12 21:21:02 +0000 | [diff] [blame] | 15 | //   bullet 1 | 
|  | 16 | template <int I, int J> struct A {}; | 
|  | 17 | template <int I> struct A<I+5, I*2> {}; // expected-error{{depends on}} | 
|  | 18 | template <int I, int J> struct B {}; | 
|  | 19 | template <int I> struct B<I, I> {}; //OK | 
|  | 20 |  | 
|  | 21 | //   bullet 2 | 
|  | 22 | template <class T, T t> struct C {};  // expected-note{{declared here}} | 
|  | 23 | template <class T> struct C<T, 1>; // expected-error{{specializes}} | 
|  | 24 | template <class T, T* t> struct C<T*, t>; // okay | 
|  | 25 |  | 
|  | 26 | template< int X, int (*array_ptr)[X] > class A2 {}; // expected-note{{here}} | 
|  | 27 | int array[5]; | 
| Douglas Gregor | 5488865 | 2009-10-07 00:13:32 +0000 | [diff] [blame] | 28 | template< int X > class A2<X, &array> { }; // expected-error{{specializes}} | 
| Douglas Gregor | 8cfd2ba | 2009-06-12 21:21:02 +0000 | [diff] [blame] | 29 |  | 
| Douglas Gregor | d522205 | 2009-06-12 19:43:02 +0000 | [diff] [blame] | 30 | template<typename T, int N, template<typename X> class TT> | 
|  | 31 | struct Test0; | 
|  | 32 |  | 
| Douglas Gregor | 09a3023 | 2009-06-12 22:08:06 +0000 | [diff] [blame] | 33 | //   bullet 3 | 
|  | 34 | template<typename T, int N, template<typename X> class TT> | 
|  | 35 | struct Test0<T, N, TT>; // expected-error{{does not specialize}} | 
|  | 36 |  | 
|  | 37 | // C++ [temp.class.spec]p10 | 
| Douglas Gregor | d522205 | 2009-06-12 19:43:02 +0000 | [diff] [blame] | 38 | template<typename T = int, // expected-error{{default template argument}} | 
|  | 39 | int N = 17, // expected-error{{default template argument}} | 
|  | 40 | template<typename X> class TT = ::vector> // expected-error{{default template argument}} | 
|  | 41 | struct Test0<T*, N, TT> { }; | 
| Douglas Gregor | 91772d1 | 2009-06-13 00:26:55 +0000 | [diff] [blame] | 42 |  | 
|  | 43 | template<typename T> struct Test1; | 
|  | 44 | template<typename T, typename U>  // expected-note{{non-deducible}} | 
|  | 45 | struct Test1<T*> { }; // expected-warning{{never be used}} |