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