blob: 397094218af837facf75206391ba652daaec110b [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Jeffrey Yasskindb88d8a2010-04-08 00:03:06 +00002template<typename T> class A; // expected-note 2 {{template parameter is declared here}} expected-note{{template is declared here}}
Douglas Gregorc15cb382009-02-09 23:23:08 +00003
4// [temp.arg.type]p1
Douglas Gregor39a8de12009-02-25 19:37:18 +00005A<0> *a1; // expected-error{{template argument for template type parameter must be a type}}
Douglas Gregorc15cb382009-02-09 23:23:08 +00006
Jeffrey Yasskindb88d8a2010-04-08 00:03:06 +00007A<A> *a2; // expected-error{{use of class template A requires template arguments}}
Douglas Gregorc15cb382009-02-09 23:23:08 +00008
9A<int> *a3;
Douglas Gregor8b642592009-02-10 00:53:15 +000010A<int()> *a4;
11A<int(float)> *a5;
Douglas Gregorc15cb382009-02-09 23:23:08 +000012A<A<int> > *a6;
13
Jeffrey Yasskindb88d8a2010-04-08 00:03:06 +000014// Pass an overloaded function template:
15template<typename T> void function_tpl(T);
16A<function_tpl> a7; // expected-error{{template argument for template type parameter must be a type}}
17
18// Pass a qualified name:
19namespace ns {
20template<typename T> class B {}; // expected-note{{template is declared here}}
21}
22A<ns::B> a8; // expected-error{{use of class template ns::B requires template arguments}}
23
Douglas Gregorc15cb382009-02-09 23:23:08 +000024// [temp.arg.type]p2
25void f() {
26 class X { };
Chandler Carruth17fb8552010-09-03 21:12:34 +000027 A<X> * a = 0; // expected-warning{{template argument uses local type 'X'}}
Douglas Gregorc15cb382009-02-09 23:23:08 +000028}
29
30struct { int x; } Unnamed; // expected-note{{unnamed type used in template argument was declared here}}
Chandler Carruth17fb8552010-09-03 21:12:34 +000031A<__typeof__(Unnamed)> *a9; // expected-warning{{template argument uses unnamed type}}
Douglas Gregorc15cb382009-02-09 23:23:08 +000032
Douglas Gregord57a38e2010-04-23 16:25:07 +000033template<typename T, unsigned N>
34struct Array {
35 typedef struct { T x[N]; } type;
36};
37
38template<typename T> struct A1 { };
39A1<Array<int, 17>::type> ax;
40
Douglas Gregorc15cb382009-02-09 23:23:08 +000041// FIXME: [temp.arg.type]p3. The check doesn't really belong here (it
42// belongs somewhere in the template instantiation section).