blob: 6b129a5369fbfcf9f564f38ac557d18071e27de2 [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregord5222052009-06-12 19:43:02 +00002template<typename T> struct vector;
3
Douglas Gregor30b01972009-06-12 22:21:45 +00004// C++ [temp.class.spec]p6:
5namespace N {
6 namespace M {
7 template<typename T> struct A; // expected-note{{here}}
8 }
9}
Douglas Gregor8cfd2ba2009-06-12 21:21:02 +000010
Douglas Gregor30b01972009-06-12 22:21:45 +000011template<typename T>
Douglas Gregor8ce63152010-09-12 05:24:55 +000012struct N::M::A<T*> { }; // expected-warning{{originally}}
Douglas Gregor30b01972009-06-12 22:21:45 +000013
14// C++ [temp.class.spec]p9
Douglas Gregor8cfd2ba2009-06-12 21:21:02 +000015// bullet 1
16template <int I, int J> struct A {};
17template <int I> struct A<I+5, I*2> {}; // expected-error{{depends on}}
18template <int I, int J> struct B {};
19template <int I> struct B<I, I> {}; //OK
20
21// bullet 2
22template <class T, T t> struct C {}; // expected-note{{declared here}}
23template <class T> struct C<T, 1>; // expected-error{{specializes}}
24template <class T, T* t> struct C<T*, t>; // okay
25
26template< int X, int (*array_ptr)[X] > class A2 {}; // expected-note{{here}}
27int array[5];
Douglas Gregor54888652009-10-07 00:13:32 +000028template< int X > class A2<X, &array> { }; // expected-error{{specializes}}
Douglas Gregor8cfd2ba2009-06-12 21:21:02 +000029
Douglas Gregord5222052009-06-12 19:43:02 +000030template<typename T, int N, template<typename X> class TT>
31struct Test0;
32
Douglas Gregor09a30232009-06-12 22:08:06 +000033// bullet 3
34template<typename T, int N, template<typename X> class TT>
35struct Test0<T, N, TT>; // expected-error{{does not specialize}}
36
37// C++ [temp.class.spec]p10
Douglas Gregord5222052009-06-12 19:43:02 +000038template<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 Gregor91772d12009-06-13 00:26:55 +000042
43template<typename T> struct Test1;
44template<typename T, typename U> // expected-note{{non-deducible}}
45 struct Test1<T*> { }; // expected-warning{{never be used}}