1// RUN: %clang_cc1 -fsyntax-only -verify %s
2// RUN: %clang_cc1 -fsyntax-only -verify %s -fdelayed-template-parsing
3
4template<typename T> struct A {};
5
6// Check for template argument lists followed by junk
7// FIXME: The diagnostics here aren't great...
8A<int+> int x; // expected-error {{expected '>'}} expected-error {{expected unqualified-id}}
9A<int x; // expected-error {{type-id cannot have a name}} expected-error {{expected '>'}}
10
11// PR8912
12template <bool> struct S {};
13S<bool(2 > 1)> s;
14
15// Test behavior when a template-id is ended by a token which starts with '>'.
16namespace greatergreater {
17  template<typename T> struct S { S(); S(T); };
18  void f(S<int>=0); // expected-error {{a space is required between a right angle bracket and an equals sign (use '> =')}}
19  void f(S<S<int>>=S<int>()); // expected-error {{use '> >'}} expected-error {{use '> ='}}
20  template<typename T> void t();
21  void g() {
22    void (*p)() = &t<int>;
23    (void)(&t<int>==p); // expected-error {{use '> ='}}
24    (void)(&t<int>>=p); // expected-error {{use '> >'}}
25    (void)(&t<S<int>>>=p); // expected-error {{use '> >'}}
26    (void)(&t<S<int>>==p); // expected-error {{use '> >'}} expected-error {{use '> ='}}
27  }
28}
29
30namespace PR5925 {
31  template <typename x>
32  class foo { // expected-note {{here}}
33  };
34  void bar(foo *X) { // expected-error {{requires template arguments}}
35  }
36}
37
38namespace PR13210 {
39  template <class T>
40  class C {}; // expected-note {{here}}
41
42  void f() {
43    new C(); // expected-error {{requires template arguments}}
44  }
45}
46
47// Don't emit spurious messages
48namespace pr16225add {
49
50  template<class T1, typename T2> struct Known { }; // expected-note 3 {{template is declared here}}
51  template<class T1, typename T2> struct X;
52  template<class T1, typename T2> struct ABC; // expected-note {{template is declared here}}
53  template<int N1, int N2> struct ABC2 {};
54
55  template<class T1, typename T2> struct foo :
56    UnknownBase<T1,T2> // expected-error {{unknown template name 'UnknownBase'}}
57  { };
58
59  template<class T1, typename T2> struct foo2 :
60    UnknownBase<T1,T2>, // expected-error {{unknown template name 'UnknownBase'}}
61    Known<T1>  // expected-error {{too few template arguments for class template 'Known'}}
62  { };
63
64  template<class T1, typename T2> struct foo3 :
65    UnknownBase<T1,T2,ABC<T2,T1> > // expected-error {{unknown template name 'UnknownBase'}}
66  { };
67
68  template<class T1, typename T2> struct foo4 :
69    UnknownBase<T1,ABC<T2> >, // expected-error {{unknown template name 'UnknownBase'}} \
70                              // expected-error {{too few template arguments for class template 'ABC'}}
71    Known<T1>  // expected-error {{too few template arguments for class template 'Known'}}
72  { };
73
74  template<class T1, typename T2> struct foo5 :
75    UnknownBase<T1,T2,ABC<T2,T1>> // expected-error {{unknown template name 'UnknownBase'}} \
76                                  // expected-error {{use '> >'}}
77  { };
78
79  template<class T1, typename T2> struct foo6 :
80    UnknownBase<T1,ABC<T2,T1>>, // expected-error {{unknown template name 'UnknownBase'}} \
81                                // expected-error {{use '> >'}}
82    Known<T1>  // expected-error {{too few template arguments for class template 'Known'}}
83  { };
84
85  template<class T1, typename T2, int N> struct foo7 :
86    UnknownBase<T1,T2,(N>1)> // expected-error {{unknown template name 'UnknownBase'}}
87  { };
88
89  template<class T1, typename T2> struct foo8 :
90    UnknownBase<X<int,int>,X<int,int>> // expected-error {{unknown template name 'UnknownBase'}} \
91                                       // expected-error {{use '> >'}}
92  { };
93
94  template<class T1, typename T2> struct foo9 :
95    UnknownBase<Known<int,int>,X<int,int>> // expected-error {{unknown template name 'UnknownBase'}} \
96                                           // expected-error {{use '> >'}}
97  { };
98
99  template<class T1, typename T2> struct foo10 :
100    UnknownBase<Known<int,int>,X<int,X<int,int>>> // expected-error {{unknown template name 'UnknownBase'}} \
101                                                  // expected-error {{use '> >'}}
102  { };
103
104  template<int N1, int N2> struct foo11 :
105    UnknownBase<2<N1,N2<4> // expected-error {{unknown template name 'UnknownBase'}}
106  { };
107
108}
109