type-traits.cpp revision 34eaaa523c3820dd32bcd9530148e76e87dcfa90
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2#define T(b) (b) ? 1 : -1
3#define F(b) (b) ? -1 : 1
4
5struct NonPOD { NonPOD(int); };
6
7// PODs
8enum Enum { EV };
9struct POD { Enum e; int i; float f; NonPOD* p; };
10struct Empty {};
11typedef Empty EmptyAr[10];
12typedef int Int;
13typedef Int IntAr[10];
14typedef Int IntArNB[];
15class Statics { static int priv; static NonPOD np; };
16union EmptyUnion {};
17union Union { int i; float f; };
18struct HasFunc { void f (); };
19struct HasOp { void operator *(); };
20struct HasConv { operator int(); };
21struct HasAssign { void operator =(int); };
22
23struct HasAnonymousUnion {
24  union {
25    int i;
26    float f;
27  };
28};
29
30// Not PODs
31typedef const void cvoid;
32struct Derives : POD {};
33typedef Derives DerivesAr[10];
34typedef Derives DerivesArNB[];
35struct DerivesEmpty : Empty {};
36struct HasCons { HasCons(int); };
37struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
38struct HasDest { ~HasDest(); };
39class  HasPriv { int priv; };
40class  HasProt { protected: int prot; };
41struct HasRef { int i; int& ref; HasRef() : i(0), ref(i) {} };
42struct HasNonPOD { NonPOD np; };
43struct HasVirt { virtual void Virt() {}; };
44typedef NonPOD NonPODAr[10];
45typedef HasVirt VirtAr[10];
46typedef NonPOD NonPODArNB[];
47union NonPODUnion { int i; Derives n; };
48
49struct HasNoThrowCopyAssign {
50  void operator =(const HasNoThrowCopyAssign&) throw();
51};
52struct HasMultipleCopyAssign {
53  void operator =(const HasMultipleCopyAssign&) throw();
54  void operator =(volatile HasMultipleCopyAssign&);
55};
56struct HasMultipleNoThrowCopyAssign {
57  void operator =(const HasMultipleNoThrowCopyAssign&) throw();
58  void operator =(volatile HasMultipleNoThrowCopyAssign&) throw();
59};
60
61struct HasNoThrowConstructor { HasNoThrowConstructor() throw(); };
62struct HasNoThrowConstructorWithArgs {
63  HasNoThrowConstructorWithArgs(HasCons i = HasCons(0)) throw();
64};
65
66struct HasNoThrowCopy { HasNoThrowCopy(const HasNoThrowCopy&) throw(); };
67struct HasMultipleCopy {
68  HasMultipleCopy(const HasMultipleCopy&) throw();
69  HasMultipleCopy(volatile HasMultipleCopy&);
70};
71struct HasMultipleNoThrowCopy {
72  HasMultipleNoThrowCopy(const HasMultipleNoThrowCopy&) throw();
73  HasMultipleNoThrowCopy(volatile HasMultipleNoThrowCopy&) throw();
74};
75
76struct HasVirtDest { virtual ~HasVirtDest(); };
77struct DerivedVirtDest : HasVirtDest {};
78typedef HasVirtDest VirtDestAr[1];
79
80void is_pod()
81{
82  { int arr[T(__is_pod(int))]; }
83  { int arr[T(__is_pod(Enum))]; }
84  { int arr[T(__is_pod(POD))]; }
85  { int arr[T(__is_pod(Int))]; }
86  { int arr[T(__is_pod(IntAr))]; }
87  { int arr[T(__is_pod(Statics))]; }
88  { int arr[T(__is_pod(Empty))]; }
89  { int arr[T(__is_pod(EmptyUnion))]; }
90  { int arr[T(__is_pod(Union))]; }
91  { int arr[T(__is_pod(HasFunc))]; }
92  { int arr[T(__is_pod(HasOp))]; }
93  { int arr[T(__is_pod(HasConv))]; }
94  { int arr[T(__is_pod(HasAssign))]; }
95  { int arr[T(__is_pod(IntArNB))]; }
96  { int arr[T(__is_pod(HasAnonymousUnion))]; }
97
98  { int arr[F(__is_pod(Derives))]; }
99  { int arr[F(__is_pod(DerivesAr))]; }
100  { int arr[F(__is_pod(DerivesArNB))]; }
101  { int arr[F(__is_pod(DerivesEmpty))]; }
102  { int arr[F(__is_pod(HasCons))]; }
103  { int arr[F(__is_pod(HasCopyAssign))]; }
104  { int arr[F(__is_pod(HasDest))]; }
105  { int arr[F(__is_pod(HasPriv))]; }
106  { int arr[F(__is_pod(HasProt))]; }
107  { int arr[F(__is_pod(HasRef))]; }
108  { int arr[F(__is_pod(HasVirt))]; }
109  { int arr[F(__is_pod(NonPOD))]; }
110  { int arr[F(__is_pod(HasNonPOD))]; }
111  { int arr[F(__is_pod(NonPODAr))]; }
112  { int arr[F(__is_pod(NonPODArNB))]; }
113  { int arr[F(__is_pod(void))]; }
114  { int arr[F(__is_pod(cvoid))]; }
115// { int arr[F(__is_pod(NonPODUnion))]; }
116}
117
118typedef Empty EmptyAr[10];
119struct Bit0 { int : 0; };
120struct Bit0Cons { int : 0; Bit0Cons(); };
121struct BitOnly { int x : 3; };
122//struct DerivesVirt : virtual POD {};
123
124void is_empty()
125{
126  { int arr[T(__is_empty(Empty))]; }
127  { int arr[T(__is_empty(DerivesEmpty))]; }
128  { int arr[T(__is_empty(HasCons))]; }
129  { int arr[T(__is_empty(HasCopyAssign))]; }
130  { int arr[T(__is_empty(HasDest))]; }
131  { int arr[T(__is_empty(HasFunc))]; }
132  { int arr[T(__is_empty(HasOp))]; }
133  { int arr[T(__is_empty(HasConv))]; }
134  { int arr[T(__is_empty(HasAssign))]; }
135  { int arr[T(__is_empty(Bit0))]; }
136  { int arr[T(__is_empty(Bit0Cons))]; }
137
138  { int arr[F(__is_empty(Int))]; }
139  { int arr[F(__is_empty(POD))]; }
140  { int arr[F(__is_empty(EmptyUnion))]; }
141  { int arr[F(__is_empty(EmptyAr))]; }
142  { int arr[F(__is_empty(HasRef))]; }
143  { int arr[F(__is_empty(HasVirt))]; }
144  { int arr[F(__is_empty(BitOnly))]; }
145  { int arr[F(__is_empty(void))]; }
146  { int arr[F(__is_empty(IntArNB))]; }
147  { int arr[F(__is_empty(HasAnonymousUnion))]; }
148//  { int arr[F(__is_empty(DerivesVirt))]; }
149}
150
151typedef Derives ClassType;
152
153void is_class()
154{
155  { int arr[T(__is_class(Derives))]; }
156  { int arr[T(__is_class(HasPriv))]; }
157  { int arr[T(__is_class(ClassType))]; }
158  { int arr[T(__is_class(HasAnonymousUnion))]; }
159
160  { int arr[F(__is_class(int))]; }
161  { int arr[F(__is_class(Enum))]; }
162  { int arr[F(__is_class(Int))]; }
163  { int arr[F(__is_class(IntAr))]; }
164  { int arr[F(__is_class(DerivesAr))]; }
165  { int arr[F(__is_class(Union))]; }
166  { int arr[F(__is_class(cvoid))]; }
167  { int arr[F(__is_class(IntArNB))]; }
168}
169
170typedef Union UnionAr[10];
171typedef Union UnionType;
172
173void is_union()
174{
175  { int arr[T(__is_union(Union))]; }
176  { int arr[T(__is_union(UnionType))]; }
177
178  { int arr[F(__is_union(int))]; }
179  { int arr[F(__is_union(Enum))]; }
180  { int arr[F(__is_union(Int))]; }
181  { int arr[F(__is_union(IntAr))]; }
182  { int arr[F(__is_union(UnionAr))]; }
183  { int arr[F(__is_union(cvoid))]; }
184  { int arr[F(__is_union(IntArNB))]; }
185  { int arr[F(__is_union(HasAnonymousUnion))]; }
186}
187
188typedef Enum EnumType;
189
190void is_enum()
191{
192  { int arr[T(__is_enum(Enum))]; }
193  { int arr[T(__is_enum(EnumType))]; }
194
195  { int arr[F(__is_enum(int))]; }
196  { int arr[F(__is_enum(Union))]; }
197  { int arr[F(__is_enum(Int))]; }
198  { int arr[F(__is_enum(IntAr))]; }
199  { int arr[F(__is_enum(UnionAr))]; }
200  { int arr[F(__is_enum(Derives))]; }
201  { int arr[F(__is_enum(ClassType))]; }
202  { int arr[F(__is_enum(cvoid))]; }
203  { int arr[F(__is_enum(IntArNB))]; }
204  { int arr[F(__is_enum(HasAnonymousUnion))]; }
205}
206
207typedef HasVirt Polymorph;
208struct InheritPolymorph : Polymorph {};
209
210void is_polymorphic()
211{
212  { int arr[T(__is_polymorphic(Polymorph))]; }
213  { int arr[T(__is_polymorphic(InheritPolymorph))]; }
214
215  { int arr[F(__is_polymorphic(int))]; }
216  { int arr[F(__is_polymorphic(Union))]; }
217  { int arr[F(__is_polymorphic(Int))]; }
218  { int arr[F(__is_polymorphic(IntAr))]; }
219  { int arr[F(__is_polymorphic(UnionAr))]; }
220  { int arr[F(__is_polymorphic(Derives))]; }
221  { int arr[F(__is_polymorphic(ClassType))]; }
222  { int arr[F(__is_polymorphic(Enum))]; }
223  { int arr[F(__is_polymorphic(cvoid))]; }
224  { int arr[F(__is_polymorphic(IntArNB))]; }
225}
226
227typedef Int& IntRef;
228typedef const IntAr ConstIntAr;
229typedef ConstIntAr ConstIntArAr[4];
230
231struct HasCopy {
232  HasCopy(HasCopy& cp);
233};
234
235struct HasTemplateCons {
236  HasVirt Annoying;
237
238  template <typename T>
239  HasTemplateCons(const T&);
240};
241
242void has_trivial_default_constructor() {
243  { int arr[T(__has_trivial_constructor(Int))]; }
244  { int arr[T(__has_trivial_constructor(IntAr))]; }
245  { int arr[T(__has_trivial_constructor(Union))]; }
246  { int arr[T(__has_trivial_constructor(UnionAr))]; }
247  { int arr[T(__has_trivial_constructor(POD))]; }
248  { int arr[T(__has_trivial_constructor(Derives))]; }
249  { int arr[T(__has_trivial_constructor(DerivesAr))]; }
250  { int arr[T(__has_trivial_constructor(ConstIntAr))]; }
251  { int arr[T(__has_trivial_constructor(ConstIntArAr))]; }
252  { int arr[T(__has_trivial_constructor(HasDest))]; }
253  { int arr[T(__has_trivial_constructor(HasPriv))]; }
254  { int arr[T(__has_trivial_constructor(HasCopyAssign))]; }
255  { int arr[T(__has_trivial_constructor(const Int))]; }
256
257  { int arr[F(__has_trivial_constructor(HasCons))]; }
258  { int arr[F(__has_trivial_constructor(HasRef))]; }
259  { int arr[F(__has_trivial_constructor(HasCopy))]; }
260  { int arr[F(__has_trivial_constructor(IntRef))]; }
261  { int arr[F(__has_trivial_constructor(VirtAr))]; }
262  { int arr[F(__has_trivial_constructor(void))]; }
263  { int arr[F(__has_trivial_constructor(cvoid))]; }
264  { int arr[F(__has_trivial_constructor(HasTemplateCons))]; }
265}
266
267void has_trivial_copy_constructor() {
268  { int arr[T(__has_trivial_copy(Int))]; }
269  { int arr[T(__has_trivial_copy(IntAr))]; }
270  { int arr[T(__has_trivial_copy(Union))]; }
271  { int arr[T(__has_trivial_copy(UnionAr))]; }
272  { int arr[T(__has_trivial_copy(POD))]; }
273  { int arr[T(__has_trivial_copy(Derives))]; }
274  { int arr[T(__has_trivial_copy(ConstIntAr))]; }
275  { int arr[T(__has_trivial_copy(ConstIntArAr))]; }
276  { int arr[T(__has_trivial_copy(HasDest))]; }
277  { int arr[T(__has_trivial_copy(HasPriv))]; }
278  { int arr[T(__has_trivial_copy(HasCons))]; }
279  { int arr[T(__has_trivial_copy(HasRef))]; }
280  { int arr[T(__has_trivial_copy(IntRef))]; }
281  { int arr[T(__has_trivial_copy(HasCopyAssign))]; }
282  { int arr[T(__has_trivial_copy(const Int))]; }
283
284  { int arr[F(__has_trivial_copy(HasCopy))]; }
285  { int arr[F(__has_trivial_copy(HasTemplateCons))]; }
286  { int arr[F(__has_trivial_copy(DerivesAr))]; }
287  { int arr[F(__has_trivial_copy(VirtAr))]; }
288  { int arr[F(__has_trivial_copy(void))]; }
289  { int arr[F(__has_trivial_copy(cvoid))]; }
290}
291
292void has_trivial_copy_assignment() {
293  { int arr[T(__has_trivial_assign(Int))]; }
294  { int arr[T(__has_trivial_assign(IntAr))]; }
295  { int arr[T(__has_trivial_assign(Union))]; }
296  { int arr[T(__has_trivial_assign(UnionAr))]; }
297  { int arr[T(__has_trivial_assign(POD))]; }
298  { int arr[T(__has_trivial_assign(Derives))]; }
299  { int arr[T(__has_trivial_assign(HasDest))]; }
300  { int arr[T(__has_trivial_assign(HasPriv))]; }
301  { int arr[T(__has_trivial_assign(HasCons))]; }
302  { int arr[T(__has_trivial_assign(HasRef))]; }
303  { int arr[T(__has_trivial_assign(HasCopy))]; }
304
305  { int arr[F(__has_trivial_assign(IntRef))]; }
306  { int arr[F(__has_trivial_assign(HasCopyAssign))]; }
307  { int arr[F(__has_trivial_assign(const Int))]; }
308  { int arr[F(__has_trivial_assign(ConstIntAr))]; }
309  { int arr[F(__has_trivial_assign(ConstIntArAr))]; }
310  { int arr[F(__has_trivial_assign(DerivesAr))]; }
311  { int arr[F(__has_trivial_assign(VirtAr))]; }
312  { int arr[F(__has_trivial_assign(void))]; }
313  { int arr[F(__has_trivial_assign(cvoid))]; }
314}
315
316void has_trivial_destructor() {
317  { int arr[T(__has_trivial_destructor(Int))]; }
318  { int arr[T(__has_trivial_destructor(IntAr))]; }
319  { int arr[T(__has_trivial_destructor(Union))]; }
320  { int arr[T(__has_trivial_destructor(UnionAr))]; }
321  { int arr[T(__has_trivial_destructor(POD))]; }
322  { int arr[T(__has_trivial_destructor(Derives))]; }
323  { int arr[T(__has_trivial_destructor(ConstIntAr))]; }
324  { int arr[T(__has_trivial_destructor(ConstIntArAr))]; }
325  { int arr[T(__has_trivial_destructor(HasPriv))]; }
326  { int arr[T(__has_trivial_destructor(HasCons))]; }
327  { int arr[T(__has_trivial_destructor(HasRef))]; }
328  { int arr[T(__has_trivial_destructor(HasCopy))]; }
329  { int arr[T(__has_trivial_destructor(IntRef))]; }
330  { int arr[T(__has_trivial_destructor(HasCopyAssign))]; }
331  { int arr[T(__has_trivial_destructor(const Int))]; }
332  { int arr[T(__has_trivial_destructor(DerivesAr))]; }
333  { int arr[T(__has_trivial_destructor(VirtAr))]; }
334
335  { int arr[F(__has_trivial_destructor(HasDest))]; }
336  { int arr[F(__has_trivial_destructor(void))]; }
337  { int arr[F(__has_trivial_destructor(cvoid))]; }
338}
339
340struct A { ~A() {} };
341template<typename> struct B : A { };
342
343void f() {
344  { int arr[F(__has_trivial_destructor(A))]; }
345  { int arr[F(__has_trivial_destructor(B<int>))]; }
346}
347
348void has_nothrow_assign() {
349  { int arr[T(__has_nothrow_assign(Int))]; }
350  { int arr[T(__has_nothrow_assign(IntAr))]; }
351  { int arr[T(__has_nothrow_assign(Union))]; }
352  { int arr[T(__has_nothrow_assign(UnionAr))]; }
353  { int arr[T(__has_nothrow_assign(POD))]; }
354  { int arr[T(__has_nothrow_assign(Derives))]; }
355  { int arr[T(__has_nothrow_assign(HasDest))]; }
356  { int arr[T(__has_nothrow_assign(HasPriv))]; }
357  { int arr[T(__has_nothrow_assign(HasCons))]; }
358  { int arr[T(__has_nothrow_assign(HasRef))]; }
359  { int arr[T(__has_nothrow_assign(HasCopy))]; }
360  { int arr[T(__has_nothrow_assign(HasNoThrowCopyAssign))]; }
361  { int arr[T(__has_nothrow_assign(HasMultipleNoThrowCopyAssign))]; }
362  { int arr[T(__has_nothrow_assign(HasVirtDest))]; }
363
364  { int arr[F(__has_nothrow_assign(IntRef))]; }
365  { int arr[F(__has_nothrow_assign(HasCopyAssign))]; }
366  { int arr[F(__has_nothrow_assign(HasMultipleCopyAssign))]; }
367  { int arr[F(__has_nothrow_assign(const Int))]; }
368  { int arr[F(__has_nothrow_assign(ConstIntAr))]; }
369  { int arr[F(__has_nothrow_assign(ConstIntArAr))]; }
370  { int arr[F(__has_nothrow_assign(DerivesAr))]; }
371  { int arr[F(__has_nothrow_assign(VirtAr))]; }
372  { int arr[F(__has_nothrow_assign(void))]; }
373  { int arr[F(__has_nothrow_assign(cvoid))]; }
374}
375
376void has_nothrow_copy() {
377  { int arr[T(__has_nothrow_copy(Int))]; }
378  { int arr[T(__has_nothrow_copy(IntAr))]; }
379  { int arr[T(__has_nothrow_copy(Union))]; }
380  { int arr[T(__has_nothrow_copy(UnionAr))]; }
381  { int arr[T(__has_nothrow_copy(POD))]; }
382  { int arr[T(__has_nothrow_copy(const Int))]; }
383  { int arr[T(__has_nothrow_copy(ConstIntAr))]; }
384  { int arr[T(__has_nothrow_copy(ConstIntArAr))]; }
385  { int arr[T(__has_nothrow_copy(Derives))]; }
386  { int arr[T(__has_nothrow_copy(IntRef))]; }
387  { int arr[T(__has_nothrow_copy(HasDest))]; }
388  { int arr[T(__has_nothrow_copy(HasPriv))]; }
389  { int arr[T(__has_nothrow_copy(HasCons))]; }
390  { int arr[T(__has_nothrow_copy(HasRef))]; }
391  { int arr[T(__has_nothrow_copy(HasCopyAssign))]; }
392  { int arr[T(__has_nothrow_copy(HasNoThrowCopy))]; }
393  { int arr[T(__has_nothrow_copy(HasMultipleNoThrowCopy))]; }
394  { int arr[T(__has_nothrow_copy(HasVirtDest))]; }
395  { int arr[T(__has_nothrow_copy(HasTemplateCons))]; }
396
397  { int arr[F(__has_nothrow_copy(HasCopy))]; }
398  { int arr[F(__has_nothrow_copy(HasMultipleCopy))]; }
399  { int arr[F(__has_nothrow_copy(DerivesAr))]; }
400  { int arr[F(__has_nothrow_copy(VirtAr))]; }
401  { int arr[F(__has_nothrow_copy(void))]; }
402  { int arr[F(__has_nothrow_copy(cvoid))]; }
403}
404
405void has_nothrow_constructor() {
406  { int arr[T(__has_nothrow_constructor(Int))]; }
407  { int arr[T(__has_nothrow_constructor(IntAr))]; }
408  { int arr[T(__has_nothrow_constructor(Union))]; }
409  { int arr[T(__has_nothrow_constructor(UnionAr))]; }
410  { int arr[T(__has_nothrow_constructor(POD))]; }
411  { int arr[T(__has_nothrow_constructor(Derives))]; }
412  { int arr[T(__has_nothrow_constructor(DerivesAr))]; }
413  { int arr[T(__has_nothrow_constructor(ConstIntAr))]; }
414  { int arr[T(__has_nothrow_constructor(ConstIntArAr))]; }
415  { int arr[T(__has_nothrow_constructor(HasDest))]; }
416  { int arr[T(__has_nothrow_constructor(HasPriv))]; }
417  { int arr[T(__has_nothrow_constructor(HasCopyAssign))]; }
418  { int arr[T(__has_nothrow_constructor(const Int))]; }
419  { int arr[T(__has_nothrow_constructor(HasNoThrowConstructor))]; }
420  { int arr[T(__has_nothrow_constructor(HasVirtDest))]; }
421  // { int arr[T(__has_nothrow_constructor(VirtAr))]; } // not implemented
422
423  { int arr[F(__has_nothrow_constructor(HasCons))]; }
424  { int arr[F(__has_nothrow_constructor(HasRef))]; }
425  { int arr[F(__has_nothrow_constructor(HasCopy))]; }
426  { int arr[F(__has_nothrow_constructor(HasNoThrowConstructorWithArgs))]; }
427  { int arr[F(__has_nothrow_constructor(IntRef))]; }
428  { int arr[F(__has_nothrow_constructor(void))]; }
429  { int arr[F(__has_nothrow_constructor(cvoid))]; }
430  { int arr[F(__has_nothrow_constructor(HasTemplateCons))]; }
431}
432
433void has_virtual_destructor() {
434  { int arr[F(__has_virtual_destructor(Int))]; }
435  { int arr[F(__has_virtual_destructor(IntAr))]; }
436  { int arr[F(__has_virtual_destructor(Union))]; }
437  { int arr[F(__has_virtual_destructor(UnionAr))]; }
438  { int arr[F(__has_virtual_destructor(POD))]; }
439  { int arr[F(__has_virtual_destructor(Derives))]; }
440  { int arr[F(__has_virtual_destructor(DerivesAr))]; }
441  { int arr[F(__has_virtual_destructor(const Int))]; }
442  { int arr[F(__has_virtual_destructor(ConstIntAr))]; }
443  { int arr[F(__has_virtual_destructor(ConstIntArAr))]; }
444  { int arr[F(__has_virtual_destructor(HasDest))]; }
445  { int arr[F(__has_virtual_destructor(HasPriv))]; }
446  { int arr[F(__has_virtual_destructor(HasCons))]; }
447  { int arr[F(__has_virtual_destructor(HasRef))]; }
448  { int arr[F(__has_virtual_destructor(HasCopy))]; }
449  { int arr[F(__has_virtual_destructor(HasCopyAssign))]; }
450  { int arr[F(__has_virtual_destructor(IntRef))]; }
451  { int arr[F(__has_virtual_destructor(VirtAr))]; }
452
453  { int arr[T(__has_virtual_destructor(HasVirtDest))]; }
454  { int arr[T(__has_virtual_destructor(DerivedVirtDest))]; }
455  { int arr[F(__has_virtual_destructor(VirtDestAr))]; }
456  { int arr[F(__has_virtual_destructor(void))]; }
457  { int arr[F(__has_virtual_destructor(cvoid))]; }
458}
459
460
461class Base {};
462class Derived : Base {};
463class Derived2a : Derived {};
464class Derived2b : Derived {};
465class Derived3 : virtual Derived2a, virtual Derived2b {};
466template<typename T> struct BaseA { T a;  };
467template<typename T> struct DerivedB : BaseA<T> { };
468template<typename T> struct CrazyDerived : T { };
469
470
471class class_forward; // expected-note {{forward declaration of 'class_forward'}}
472
473template <typename Base, typename Derived>
474void isBaseOfT() {
475  int t[T(__is_base_of(Base, Derived))];
476};
477template <typename Base, typename Derived>
478void isBaseOfF() {
479  int t[F(__is_base_of(Base, Derived))];
480};
481
482template <class T> class DerivedTemp : Base {};
483template <class T> class NonderivedTemp {};
484template <class T> class UndefinedTemp; // expected-note {{declared here}}
485
486void is_base_of() {
487  { int arr[T(__is_base_of(Base, Derived))]; }
488  { int arr[T(__is_base_of(const Base, Derived))]; }
489  { int arr[F(__is_base_of(Derived, Base))]; }
490  { int arr[F(__is_base_of(Derived, int))]; }
491  { int arr[T(__is_base_of(Base, Base))]; }
492  { int arr[T(__is_base_of(Base, Derived3))]; }
493  { int arr[T(__is_base_of(Derived, Derived3))]; }
494  { int arr[T(__is_base_of(Derived2b, Derived3))]; }
495  { int arr[T(__is_base_of(Derived2a, Derived3))]; }
496  { int arr[T(__is_base_of(BaseA<int>, DerivedB<int>))]; }
497  { int arr[F(__is_base_of(DerivedB<int>, BaseA<int>))]; }
498  { int arr[T(__is_base_of(Base, CrazyDerived<Base>))]; }
499  { int arr[F(__is_base_of(Union, Union))]; }
500  { int arr[T(__is_base_of(Empty, Empty))]; }
501  { int arr[T(__is_base_of(class_forward, class_forward))]; }
502  { int arr[F(__is_base_of(Empty, class_forward))]; } // expected-error {{incomplete type 'class_forward' used in type trait expression}}
503  { int arr[F(__is_base_of(Base&, Derived&))]; }
504  int t18[F(__is_base_of(Base[10], Derived[10]))];
505  { int arr[F(__is_base_of(int, int))]; }
506  { int arr[F(__is_base_of(long, int))]; }
507  { int arr[T(__is_base_of(Base, DerivedTemp<int>))]; }
508  { int arr[F(__is_base_of(Base, NonderivedTemp<int>))]; }
509  { int arr[F(__is_base_of(Base, UndefinedTemp<int>))]; } // expected-error {{implicit instantiation of undefined template 'UndefinedTemp<int>'}}
510
511  isBaseOfT<Base, Derived>();
512  isBaseOfF<Derived, Base>();
513
514  isBaseOfT<Base, CrazyDerived<Base> >();
515  isBaseOfF<CrazyDerived<Base>, Base>();
516
517  isBaseOfT<BaseA<int>, DerivedB<int> >();
518  isBaseOfF<DerivedB<int>, BaseA<int> >();
519}
520
521struct FromInt { FromInt(int); };
522struct ToInt { operator int(); };
523typedef void Function();
524
525void is_convertible_to();
526class PrivateCopy {
527  PrivateCopy(const PrivateCopy&);
528  friend void is_convertible_to();
529};
530
531template<typename T>
532struct X0 {
533  template<typename U> X0(const X0<U>&);
534};
535
536void is_convertible_to() {
537  { int arr[T(__is_convertible_to(Int, Int))]; }
538  { int arr[F(__is_convertible_to(Int, IntAr))]; }
539  { int arr[F(__is_convertible_to(IntAr, IntAr))]; }
540  { int arr[T(__is_convertible_to(void, void))]; }
541  { int arr[T(__is_convertible_to(cvoid, void))]; }
542  { int arr[T(__is_convertible_to(void, cvoid))]; }
543  { int arr[T(__is_convertible_to(cvoid, cvoid))]; }
544  { int arr[T(__is_convertible_to(int, FromInt))]; }
545  { int arr[T(__is_convertible_to(long, FromInt))]; }
546  { int arr[T(__is_convertible_to(double, FromInt))]; }
547  { int arr[T(__is_convertible_to(const int, FromInt))]; }
548  { int arr[T(__is_convertible_to(const int&, FromInt))]; }
549  { int arr[T(__is_convertible_to(ToInt, int))]; }
550  { int arr[T(__is_convertible_to(ToInt, const int&))]; }
551  { int arr[T(__is_convertible_to(ToInt, long))]; }
552  { int arr[F(__is_convertible_to(ToInt, int&))]; }
553  { int arr[F(__is_convertible_to(ToInt, FromInt))]; }
554  { int arr[T(__is_convertible_to(IntAr&, IntAr&))]; }
555  { int arr[T(__is_convertible_to(IntAr&, const IntAr&))]; }
556  { int arr[F(__is_convertible_to(const IntAr&, IntAr&))]; }
557  { int arr[F(__is_convertible_to(Function, Function))]; }
558  { int arr[F(__is_convertible_to(PrivateCopy, PrivateCopy))]; }
559  { int arr[T(__is_convertible_to(X0<int>, X0<float>))]; }
560}
561
562void is_trivial()
563{
564  { int arr[T(__is_trivial(int))]; }
565  { int arr[T(__is_trivial(Enum))]; }
566  { int arr[T(__is_trivial(POD))]; }
567  { int arr[T(__is_trivial(Int))]; }
568  { int arr[T(__is_trivial(IntAr))]; }
569  { int arr[T(__is_trivial(Statics))]; }
570  { int arr[T(__is_trivial(Empty))]; }
571  { int arr[T(__is_trivial(EmptyUnion))]; }
572  { int arr[T(__is_trivial(Union))]; }
573  { int arr[T(__is_trivial(Derives))]; }
574  { int arr[T(__is_trivial(DerivesAr))]; }
575  { int arr[T(__is_trivial(DerivesEmpty))]; }
576  { int arr[T(__is_trivial(HasFunc))]; }
577  { int arr[T(__is_trivial(HasOp))]; }
578  { int arr[T(__is_trivial(HasConv))]; }
579  { int arr[T(__is_trivial(HasAssign))]; }
580  { int arr[T(__is_trivial(HasAnonymousUnion))]; }
581  { int arr[T(__is_trivial(HasPriv))]; }
582  { int arr[T(__is_trivial(HasProt))]; }
583
584  { int arr[F(__is_trivial(HasCons))]; }
585  { int arr[F(__is_trivial(HasCopyAssign))]; }
586  { int arr[F(__is_trivial(HasDest))]; }
587  { int arr[F(__is_trivial(HasRef))]; }
588  { int arr[F(__is_trivial(HasNonPOD))]; }
589  { int arr[F(__is_trivial(HasVirt))]; }
590  { int arr[F(__is_trivial(IntArNB))]; }
591  { int arr[F(__is_trivial(DerivesArNB))]; }
592  { int arr[F(__is_trivial(void))]; }
593  { int arr[F(__is_trivial(cvoid))]; }
594}
595