1 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
2 template<typename T
, typename U
>
5 (void)(x
+ y
); // expected-error{{invalid operands}}
11 template struct X0
<int, float>;
12 template struct X0
<int*, int>;
13 template struct X0
<int X1::*, int>; // expected-note{{instantiation of}}
21 T
*xp
= &x
, &yr
= y
; // expected-error{{pointer to a reference}}
26 template struct X2
<int>;
27 template struct X2
<int&>; // expected-note{{instantiation of}}
38 template struct X3
<int>;
40 template <typename T
> struct X4
{
42 return; // expected-error{{non-void function 'f' should return a value}}
46 return 1; // expected-error{{void function 'g' should not return a value}}
50 template struct X4
<void>; // expected-note{{in instantiation of}}
51 template struct X4
<int>; // expected-note{{in instantiation of}}
53 struct Incomplete
; // expected-note 2{{forward declaration}}
55 template<typename T
> struct X5
{
56 T
f() { } // expected-error{{incomplete result type}}
58 void test_X5(X5
<Incomplete
> x5
); // okay!
60 template struct X5
<Incomplete
>; // expected-note{{instantiation}}
62 template<typename T
, typename U
, typename V
> struct X6
{
69 return v
; // expected-error{{cannot initialize return object of type}}
75 return v
; // expected-error{{cannot initialize return object of type}}
79 struct ConvertibleToInt
{
83 template struct X6
<ConvertibleToInt
, float, char>;
84 template struct X6
<bool, int, int*>; // expected-note{{instantiation}}
86 template <typename T
> struct X7
{
92 template struct X7
<int>;
94 template<typename T
> struct While0
{
103 template struct While0
<float>;
105 template<typename T
> struct Do0
{
108 } while (t
); // expected-error{{not contextually}}
112 struct NotConvertibleToBool
{ };
113 template struct Do0
<ConvertibleToInt
>;
114 template struct Do0
<NotConvertibleToBool
>; // expected-note{{instantiation}}
116 template<typename T
> struct For0
{
118 for (; f
!= l
; ++f
) {
127 template struct For0
<int*>;
129 template<typename T
> struct Member0
{
136 tp
.f
; // expected-error{{member reference base type 'T *' is not a structure or union}}
139 this->f
; // expected-error{{reference to non-static member function must be called}}
140 this.f
; // expected-error{{member reference base type 'Member0<T> *' is not a structure or union}}
144 template<typename T
, typename U
> struct Switch0
{
145 U
f(T value
, U v0
, U v1
, U v2
) {
151 case 2: // fall through
159 template struct Switch0
<int, float>;
161 template<typename T
, int I1
, int I2
> struct Switch1
{
164 case I1
: return y
; // expected-note{{previous}}
165 case I2
: return z
; // expected-error{{duplicate}}
171 template struct Switch1
<int, 1, 2>;
172 template struct Switch1
<int, 2, 2>; // expected-note{{instantiation}}
174 template<typename T
> struct IndirectGoto0
{
176 // FIXME: crummy error message below
177 goto *x
; // expected-error{{incompatible}}
181 prior_label
= &&prior
; // expected-error{{assigning to 'int'}}
184 later_label
= &&later
; // expected-error{{assigning to 'int'}}
191 template struct IndirectGoto0
<void*>;
192 template struct IndirectGoto0
<int>; // expected-note{{instantiation}}
194 template<typename T
> struct TryCatch0
{
197 } catch (T t
) { // expected-error{{incomplete type}} \
198 // expected-error{{abstract class}}
205 virtual void foo() = 0; // expected-note{{pure virtual}}
208 template struct TryCatch0
<int>; // okay
209 template struct TryCatch0
<Incomplete
*>; // expected-note{{instantiation}}
210 template struct TryCatch0
<Abstract
>; // expected-note{{instantiation}}
213 template<typename T
> struct X
;
214 template<typename T
> struct Y
: public X
<T
> {
215 Y
& x() { return *this; }
218 // Make sure our assertions don't get too uppity.
220 template <class T
> class A
{ void foo(T array
[10]); };
221 template class A
<int>;
225 template<typename T
> void f() { T x
= x
; }
226 template void f
<int>();
231 struct no_tag
{ char a
; }; // (A)
232 struct yes_tag
{ long a
; long b
; }; // (A)
234 template <typename T
>
235 struct HasIndexMetamethod
{
236 template <typename U
>
237 static no_tag
check(...);
238 template <typename U
>
239 static yes_tag
check(char[sizeof(&U::luaIndex
)]);
240 enum { value
= sizeof(check
<T
>(0)) == sizeof(yes_tag
) };
245 int luaIndex(lua_State
* L
);
248 int i
= HasIndexMetamethod
<SomeClass
>::value
;