blob: e9b855ae6c1329dbab6191008b9ef33588ee1ca6 [file] [log] [blame]
Daniel Dunbare2a3e9a2009-07-11 22:00:53 +00001// FIXME: This should not require -disable-free.
2// RUN: clang-cc -disable-free -fsyntax-only -verify %s
Douglas Gregorba1ecb52009-06-12 19:43:02 +00003template<typename T> struct vector;
4
Douglas Gregor16df8502009-06-12 22:21:45 +00005// C++ [temp.class.spec]p6:
6namespace N {
7 namespace M {
8 template<typename T> struct A; // expected-note{{here}}
9 }
10}
Douglas Gregore94866f2009-06-12 21:21:02 +000011
Douglas Gregor16df8502009-06-12 22:21:45 +000012template<typename T>
13struct N::M::A<T*> { }; // expected-error{{not in namespace}}
14
15// C++ [temp.class.spec]p9
Douglas Gregore94866f2009-06-12 21:21:02 +000016// bullet 1
17template <int I, int J> struct A {};
18template <int I> struct A<I+5, I*2> {}; // expected-error{{depends on}}
19template <int I, int J> struct B {};
20template <int I> struct B<I, I> {}; //OK
21
22// bullet 2
23template <class T, T t> struct C {}; // expected-note{{declared here}}
24template <class T> struct C<T, 1>; // expected-error{{specializes}}
25template <class T, T* t> struct C<T*, t>; // okay
26
27template< int X, int (*array_ptr)[X] > class A2 {}; // expected-note{{here}}
28int array[5];
29template< int X > class A2<X,&array> { }; // expected-error{{specializes}}
30
Douglas Gregorba1ecb52009-06-12 19:43:02 +000031template<typename T, int N, template<typename X> class TT>
32struct Test0;
33
Douglas Gregor6aa75cf2009-06-12 22:08:06 +000034// bullet 3
35template<typename T, int N, template<typename X> class TT>
36struct Test0<T, N, TT>; // expected-error{{does not specialize}}
37
38// C++ [temp.class.spec]p10
Douglas Gregorba1ecb52009-06-12 19:43:02 +000039template<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 Gregor031a5882009-06-13 00:26:55 +000043
44template<typename T> struct Test1;
45template<typename T, typename U> // expected-note{{non-deducible}}
46 struct Test1<T*> { }; // expected-warning{{never be used}}