aboutsummaryrefslogtreecommitdiff
path: root/test/Parser/cxx-template-decl.cpp
blob: e415ba15f2c103f5af57db2efda805769f29244a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// RUN: clang -fsyntax-only -verify %s

// Errors
export class foo { };   // expected-error {{expected template}}
template  x;            // expected-error {{expected '<' after 'template'}}
export template x;      // expected-error {{expected '<' after 'template'}}
template < ;            // expected-error {{parse error}}
template <template X> ; // expected-error {{expected '<' after 'template'}}
template <template <typename> > ;       // expected-error {{expected 'class' before '>'}}
template <template <typename> Foo> ;    // expected-error {{expected 'class' before 'Foo'}}

// Template function declarations
template <typename T> void foo();
template <typename T, typename U> void foo();

// Template function definitions.
template <typename T> void foo() { }

// Template class (forward) declarations
template <typename T> struct A;
template <typename T, typename U> struct b;
template <typename> struct C;
template <typename, typename> struct D;

// Forward declarations with default parameters?
template <typename T = int> X1;
template <typename = int> X2;

// Forward declarations w/template template parameters
template <template <typename> class T> class TTP1;
template <template <typename> class> class TTP2;
template <template <typename> class T = foo> TTP3;
template <template <typename> class = foo> TTP3;
template <template <typename X, typename Y> class T> TTP5;

// Forward declararations with non-type params
template <int> class NTP0;
template <int N> class NTP1;
template <int N = 5> class NTP2;
template <int = 10> class NTP3;
template <unsigned int N = 12u> NTP4;;
template <unsigned int = 12u> NTP5;
template <unsigned = 15u> NTP6;
template <typename T, T Obj> NTP7;      // expected-error {{parse error}}

// Template class declarations
template <typename T> struct A { };
template <typename T, typename U> struct B { };