Home | History | Annotate | Download | only in SemaTemplate
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 template<typename T> class A; // expected-note 2 {{template parameter is declared here}} expected-note{{template is declared here}}
      3 
      4 // [temp.arg.type]p1
      5 A<0> *a1; // expected-error{{template argument for template type parameter must be a type}}
      6 
      7 A<A> *a2; // expected-error{{use of class template 'A' requires template arguments}}
      8 
      9 A<int> *a3;
     10 A<int()> *a4;
     11 A<int(float)> *a5;
     12 A<A<int> > *a6;
     13 
     14 // Pass an overloaded function template:
     15 template<typename T> void function_tpl(T);
     16 A<function_tpl> a7;  // expected-error{{template argument for template type parameter must be a type}}
     17 
     18 // Pass a qualified name:
     19 namespace ns {
     20 template<typename T> class B {};  // expected-note{{template is declared here}}
     21 }
     22 A<ns::B> a8; // expected-error{{use of class template 'ns::B' requires template arguments}}
     23 
     24 // [temp.arg.type]p2
     25 void f() {
     26   class X { };
     27   A<X> * a = 0; // expected-warning{{template argument uses local type 'X'}}
     28 }
     29 
     30 struct { int x; } Unnamed; // expected-note{{unnamed type used in template argument was declared here}}
     31 A<__typeof__(Unnamed)> *a9; // expected-warning{{template argument uses unnamed type}}
     32 
     33 template<typename T, unsigned N>
     34 struct Array {
     35   typedef struct { T x[N]; } type;
     36 };
     37 
     38 template<typename T> struct A1 { };
     39 A1<Array<int, 17>::type> ax;
     40 
     41 // FIXME: [temp.arg.type]p3. The check doesn't really belong here (it
     42 // belongs somewhere in the template instantiation section).
     43