Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Jeffrey Yasskin | db88d8a | 2010-04-08 00:03:06 +0000 | [diff] [blame] | 2 | template<typename T> class A; // expected-note 2 {{template parameter is declared here}} expected-note{{template is declared here}} |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 3 | |
| 4 | // [temp.arg.type]p1 |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 5 | A<0> *a1; // expected-error{{template argument for template type parameter must be a type}} |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 6 | |
Jeffrey Yasskin | db88d8a | 2010-04-08 00:03:06 +0000 | [diff] [blame] | 7 | A<A> *a2; // expected-error{{use of class template A requires template arguments}} |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 8 | |
| 9 | A<int> *a3; |
Douglas Gregor | 8b64259 | 2009-02-10 00:53:15 +0000 | [diff] [blame] | 10 | A<int()> *a4; |
| 11 | A<int(float)> *a5; |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 12 | A<A<int> > *a6; |
| 13 | |
Jeffrey Yasskin | db88d8a | 2010-04-08 00:03:06 +0000 | [diff] [blame] | 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 | |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 24 | // [temp.arg.type]p2 |
| 25 | void f() { |
| 26 | class X { }; |
Chandler Carruth | 17fb855 | 2010-09-03 21:12:34 +0000 | [diff] [blame] | 27 | A<X> * a = 0; // expected-warning{{template argument uses local type 'X'}} |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | struct { int x; } Unnamed; // expected-note{{unnamed type used in template argument was declared here}} |
Chandler Carruth | 17fb855 | 2010-09-03 21:12:34 +0000 | [diff] [blame] | 31 | A<__typeof__(Unnamed)> *a9; // expected-warning{{template argument uses unnamed type}} |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 32 | |
Douglas Gregor | d57a38e | 2010-04-23 16:25:07 +0000 | [diff] [blame] | 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 | |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 41 | // FIXME: [temp.arg.type]p3. The check doesn't really belong here (it |
| 42 | // belongs somewhere in the template instantiation section). |