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