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