[lld][WebAssembly] Reinstate mistakenly disabled test. NFC
[llvm-project.git] / clang / test / SemaCXX / type-traits.cpp
blobd576e4388d6f32e85c9c0c1ccd0e47c114c01d4d
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fms-extensions -Wno-microsoft %s
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fms-extensions -Wno-microsoft %s
3 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -fms-extensions -Wno-microsoft %s
5 #define T(b) (b) ? 1 : -1
6 #define F(b) (b) ? -1 : 1
8 struct NonPOD { NonPOD(int); };
9 typedef NonPOD NonPODAr[10];
10 typedef NonPOD NonPODArNB[];
11 typedef NonPOD NonPODArMB[10][2];
13 // PODs
14 enum Enum { EV };
15 enum SignedEnum : signed int { };
16 enum UnsignedEnum : unsigned int { };
17 struct POD { Enum e; int i; float f; NonPOD* p; };
18 struct Empty {};
19 struct IncompleteStruct;
20 typedef Empty EmptyAr[10];
21 typedef Empty EmptyArNB[];
22 typedef Empty EmptyArMB[1][2];
23 typedef int Int;
24 typedef Int IntAr[10];
25 typedef Int IntArNB[];
26 class Statics { static int priv; static NonPOD np; };
27 union EmptyUnion {};
28 union IncompleteUnion; // expected-note {{forward declaration of 'IncompleteUnion'}}
29 union Union { int i; float f; };
30 struct HasFunc { void f (); };
31 struct HasOp { void operator *(); };
32 struct HasConv { operator int(); };
33 struct HasAssign { void operator =(int); };
35 struct HasAnonymousUnion {
36 union {
37 int i;
38 float f;
42 typedef int Vector __attribute__((vector_size(16)));
43 typedef int VectorExt __attribute__((ext_vector_type(4)));
45 using ComplexFloat = _Complex float;
46 using ComplexInt = _Complex int;
48 // Not PODs
49 typedef const void cvoid;
50 struct Derives : POD {};
51 typedef Derives DerivesAr[10];
52 typedef Derives DerivesArNB[];
53 struct DerivesEmpty : Empty {};
54 struct HasCons { HasCons(int); };
55 struct HasDefaultCons { HasDefaultCons() = default; };
56 struct HasExplicitDefaultCons { explicit HasExplicitDefaultCons() = default; };
57 struct HasInheritedCons : HasDefaultCons { using HasDefaultCons::HasDefaultCons; };
58 struct HasNoInheritedCons : HasCons {};
59 struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
60 struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
61 struct HasNoThrowMoveAssign {
62 HasNoThrowMoveAssign& operator=(
63 const HasNoThrowMoveAssign&&) throw(); };
64 struct HasNoExceptNoThrowMoveAssign {
65 HasNoExceptNoThrowMoveAssign& operator=(
66 const HasNoExceptNoThrowMoveAssign&&) noexcept;
68 struct HasThrowMoveAssign {
69 HasThrowMoveAssign& operator=(const HasThrowMoveAssign&&)
70 #if __cplusplus <= 201402L
71 throw(POD);
72 #else
73 noexcept(false);
74 #endif
78 struct HasNoExceptFalseMoveAssign {
79 HasNoExceptFalseMoveAssign& operator=(
80 const HasNoExceptFalseMoveAssign&&) noexcept(false); };
81 struct HasMoveCtor { HasMoveCtor(const HasMoveCtor&&); };
82 struct HasMemberMoveCtor { HasMoveCtor member; };
83 struct HasMemberMoveAssign { HasMoveAssign member; };
84 struct HasStaticMemberMoveCtor { static HasMoveCtor member; };
85 struct HasStaticMemberMoveAssign { static HasMoveAssign member; };
86 struct HasMemberThrowMoveAssign { HasThrowMoveAssign member; };
87 struct HasMemberNoExceptFalseMoveAssign {
88 HasNoExceptFalseMoveAssign member; };
89 struct HasMemberNoThrowMoveAssign { HasNoThrowMoveAssign member; };
90 struct HasMemberNoExceptNoThrowMoveAssign {
91 HasNoExceptNoThrowMoveAssign member; };
93 struct HasDefaultTrivialCopyAssign {
94 HasDefaultTrivialCopyAssign &operator=(
95 const HasDefaultTrivialCopyAssign&) = default;
97 struct TrivialMoveButNotCopy {
98 TrivialMoveButNotCopy &operator=(TrivialMoveButNotCopy&&) = default;
99 TrivialMoveButNotCopy &operator=(const TrivialMoveButNotCopy&);
101 struct NonTrivialDefault {
102 NonTrivialDefault();
105 struct HasDest { ~HasDest(); };
106 class HasPriv { int priv; };
107 class HasProt { protected: int prot; };
108 struct HasRef { int i; int& ref; HasRef() : i(0), ref(i) {} };
109 struct HasRefAggregate { int i; int& ref; };
110 struct HasNonPOD { NonPOD np; };
111 struct HasVirt { virtual void Virt() {}; };
112 typedef NonPOD NonPODAr[10];
113 typedef HasVirt VirtAr[10];
114 typedef NonPOD NonPODArNB[];
115 union NonPODUnion { int i; Derives n; };
116 struct DerivesHasCons : HasCons {};
117 struct DerivesHasCopyAssign : HasCopyAssign {};
118 struct DerivesHasMoveAssign : HasMoveAssign {};
119 struct DerivesHasDest : HasDest {};
120 struct DerivesHasPriv : HasPriv {};
121 struct DerivesHasProt : HasProt {};
122 struct DerivesHasRef : HasRef {};
123 struct DerivesHasVirt : HasVirt {};
124 struct DerivesHasMoveCtor : HasMoveCtor {};
126 struct HasNoThrowCopyAssign {
127 void operator =(const HasNoThrowCopyAssign&) throw();
129 struct HasMultipleCopyAssign {
130 void operator =(const HasMultipleCopyAssign&) throw();
131 void operator =(volatile HasMultipleCopyAssign&);
133 struct HasMultipleNoThrowCopyAssign {
134 void operator =(const HasMultipleNoThrowCopyAssign&) throw();
135 void operator =(volatile HasMultipleNoThrowCopyAssign&) throw();
138 struct HasNoThrowConstructor { HasNoThrowConstructor() throw(); };
139 struct HasNoThrowConstructorWithArgs {
140 HasNoThrowConstructorWithArgs(HasCons i = HasCons(0)) throw();
142 struct HasMultipleDefaultConstructor1 {
143 HasMultipleDefaultConstructor1() throw();
144 HasMultipleDefaultConstructor1(int i = 0);
146 struct HasMultipleDefaultConstructor2 {
147 HasMultipleDefaultConstructor2(int i = 0);
148 HasMultipleDefaultConstructor2() throw();
151 struct HasNoThrowCopy { HasNoThrowCopy(const HasNoThrowCopy&) throw(); };
152 struct HasMultipleCopy {
153 HasMultipleCopy(const HasMultipleCopy&) throw();
154 HasMultipleCopy(volatile HasMultipleCopy&);
156 struct HasMultipleNoThrowCopy {
157 HasMultipleNoThrowCopy(const HasMultipleNoThrowCopy&) throw();
158 HasMultipleNoThrowCopy(volatile HasMultipleNoThrowCopy&) throw();
161 struct HasVirtDest { virtual ~HasVirtDest(); };
162 struct DerivedVirtDest : HasVirtDest {};
163 typedef HasVirtDest VirtDestAr[1];
165 class AllPrivate {
166 AllPrivate() throw();
167 AllPrivate(const AllPrivate&) throw();
168 AllPrivate &operator=(const AllPrivate &) throw();
169 ~AllPrivate() throw();
172 struct ThreeArgCtor {
173 ThreeArgCtor(int*, char*, int);
176 struct VariadicCtor {
177 template<typename...T> VariadicCtor(T...);
180 struct ThrowingDtor {
181 ~ThrowingDtor()
182 #if __cplusplus <= 201402L
183 throw(int);
184 #else
185 noexcept(false);
186 #endif
189 struct NoExceptDtor {
190 ~NoExceptDtor() noexcept(true);
193 struct NoThrowDtor {
194 ~NoThrowDtor() throw();
197 struct ACompleteType {};
198 struct AnIncompleteType; // expected-note 1+ {{forward declaration of 'AnIncompleteType'}}
199 typedef AnIncompleteType AnIncompleteTypeAr[42];
200 typedef AnIncompleteType AnIncompleteTypeArNB[];
201 typedef AnIncompleteType AnIncompleteTypeArMB[1][10];
203 struct HasInClassInit {
204 int x = 42;
207 struct HasPrivateBase : private ACompleteType {};
208 struct HasProtectedBase : protected ACompleteType {};
209 struct HasVirtBase : virtual ACompleteType {};
211 void is_pod()
213 { int arr[T(__is_pod(int))]; }
214 { int arr[T(__is_pod(Enum))]; }
215 { int arr[T(__is_pod(POD))]; }
216 { int arr[T(__is_pod(Int))]; }
217 { int arr[T(__is_pod(IntAr))]; }
218 { int arr[T(__is_pod(Statics))]; }
219 { int arr[T(__is_pod(Empty))]; }
220 { int arr[T(__is_pod(EmptyUnion))]; }
221 { int arr[T(__is_pod(Union))]; }
222 { int arr[T(__is_pod(HasFunc))]; }
223 { int arr[T(__is_pod(HasOp))]; }
224 { int arr[T(__is_pod(HasConv))]; }
225 { int arr[T(__is_pod(HasAssign))]; }
226 { int arr[T(__is_pod(IntArNB))]; }
227 { int arr[T(__is_pod(HasAnonymousUnion))]; }
228 { int arr[T(__is_pod(Vector))]; }
229 { int arr[T(__is_pod(VectorExt))]; }
230 { int arr[T(__is_pod(Derives))]; }
231 { int arr[T(__is_pod(DerivesAr))]; }
232 { int arr[T(__is_pod(DerivesArNB))]; }
233 { int arr[T(__is_pod(DerivesEmpty))]; }
234 { int arr[T(__is_pod(HasPriv))]; }
235 { int arr[T(__is_pod(HasProt))]; }
236 { int arr[T(__is_pod(DerivesHasPriv))]; }
237 { int arr[T(__is_pod(DerivesHasProt))]; }
239 { int arr[F(__is_pod(HasCons))]; }
240 { int arr[F(__is_pod(HasCopyAssign))]; }
241 { int arr[F(__is_pod(HasMoveAssign))]; }
242 { int arr[F(__is_pod(HasDest))]; }
243 { int arr[F(__is_pod(HasRef))]; }
244 { int arr[F(__is_pod(HasVirt))]; }
245 { int arr[F(__is_pod(DerivesHasCons))]; }
246 { int arr[F(__is_pod(DerivesHasCopyAssign))]; }
247 { int arr[F(__is_pod(DerivesHasMoveAssign))]; }
248 { int arr[F(__is_pod(DerivesHasDest))]; }
249 { int arr[F(__is_pod(DerivesHasRef))]; }
250 { int arr[F(__is_pod(DerivesHasVirt))]; }
251 { int arr[F(__is_pod(NonPOD))]; }
252 { int arr[F(__is_pod(HasNonPOD))]; }
253 { int arr[F(__is_pod(NonPODAr))]; }
254 { int arr[F(__is_pod(NonPODArNB))]; }
255 { int arr[F(__is_pod(void))]; }
256 { int arr[F(__is_pod(cvoid))]; }
257 // { int arr[F(__is_pod(NonPODUnion))]; }
259 { int arr[T(__is_pod(ACompleteType))]; }
260 { int arr[F(__is_pod(AnIncompleteType))]; } // expected-error {{incomplete type}}
261 { int arr[F(__is_pod(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
262 { int arr[F(__is_pod(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
265 typedef Empty EmptyAr[10];
266 struct Bit0 { int : 0; };
267 struct Bit0Cons { int : 0; Bit0Cons(); };
268 struct AnonBitOnly { int : 3; };
269 struct BitOnly { int x : 3; };
270 struct DerivesVirt : virtual POD {};
272 void is_empty()
274 { int arr[T(__is_empty(Empty))]; }
275 { int arr[T(__is_empty(DerivesEmpty))]; }
276 { int arr[T(__is_empty(HasCons))]; }
277 { int arr[T(__is_empty(HasCopyAssign))]; }
278 { int arr[T(__is_empty(HasMoveAssign))]; }
279 { int arr[T(__is_empty(HasDest))]; }
280 { int arr[T(__is_empty(HasFunc))]; }
281 { int arr[T(__is_empty(HasOp))]; }
282 { int arr[T(__is_empty(HasConv))]; }
283 { int arr[T(__is_empty(HasAssign))]; }
284 { int arr[T(__is_empty(Bit0))]; }
285 { int arr[T(__is_empty(Bit0Cons))]; }
287 { int arr[F(__is_empty(Int))]; }
288 { int arr[F(__is_empty(POD))]; }
289 { int arr[F(__is_empty(EmptyUnion))]; }
290 { int arr[F(__is_empty(IncompleteUnion))]; }
291 { int arr[F(__is_empty(EmptyAr))]; }
292 { int arr[F(__is_empty(HasRef))]; }
293 { int arr[F(__is_empty(HasVirt))]; }
294 { int arr[F(__is_empty(AnonBitOnly))]; }
295 { int arr[F(__is_empty(BitOnly))]; }
296 { int arr[F(__is_empty(void))]; }
297 { int arr[F(__is_empty(IntArNB))]; }
298 { int arr[F(__is_empty(HasAnonymousUnion))]; }
299 // { int arr[F(__is_empty(DerivesVirt))]; }
301 { int arr[T(__is_empty(ACompleteType))]; }
302 { int arr[F(__is_empty(AnIncompleteType))]; } // expected-error {{incomplete type}}
303 { int arr[F(__is_empty(AnIncompleteType[]))]; }
304 { int arr[F(__is_empty(AnIncompleteType[1]))]; }
307 typedef Derives ClassType;
309 void is_class()
311 { int arr[T(__is_class(Derives))]; }
312 { int arr[T(__is_class(HasPriv))]; }
313 { int arr[T(__is_class(ClassType))]; }
314 { int arr[T(__is_class(HasAnonymousUnion))]; }
316 { int arr[F(__is_class(int))]; }
317 { int arr[F(__is_class(Enum))]; }
318 { int arr[F(__is_class(Int))]; }
319 { int arr[F(__is_class(IntAr))]; }
320 { int arr[F(__is_class(DerivesAr))]; }
321 { int arr[F(__is_class(Union))]; }
322 { int arr[F(__is_class(cvoid))]; }
323 { int arr[F(__is_class(IntArNB))]; }
326 typedef Union UnionAr[10];
327 typedef Union UnionType;
329 void is_union()
331 { int arr[T(__is_union(Union))]; }
332 { int arr[T(__is_union(UnionType))]; }
334 { int arr[F(__is_union(int))]; }
335 { int arr[F(__is_union(Enum))]; }
336 { int arr[F(__is_union(Int))]; }
337 { int arr[F(__is_union(IntAr))]; }
338 { int arr[F(__is_union(UnionAr))]; }
339 { int arr[F(__is_union(cvoid))]; }
340 { int arr[F(__is_union(IntArNB))]; }
341 { int arr[F(__is_union(HasAnonymousUnion))]; }
344 typedef Enum EnumType;
346 void is_enum()
348 { int arr[T(__is_enum(Enum))]; }
349 { int arr[T(__is_enum(EnumType))]; }
351 { int arr[F(__is_enum(int))]; }
352 { int arr[F(__is_enum(Union))]; }
353 { int arr[F(__is_enum(Int))]; }
354 { int arr[F(__is_enum(IntAr))]; }
355 { int arr[F(__is_enum(UnionAr))]; }
356 { int arr[F(__is_enum(Derives))]; }
357 { int arr[F(__is_enum(ClassType))]; }
358 { int arr[F(__is_enum(cvoid))]; }
359 { int arr[F(__is_enum(IntArNB))]; }
360 { int arr[F(__is_enum(HasAnonymousUnion))]; }
363 struct FinalClass final {
366 template<typename T>
367 struct PotentiallyFinal { };
369 template<typename T>
370 struct PotentiallyFinal<T*> final { };
372 template<>
373 struct PotentiallyFinal<int> final { };
375 struct SealedClass sealed {
378 template<typename T>
379 struct PotentiallySealed { };
381 template<typename T>
382 struct PotentiallySealed<T*> sealed { };
384 template<>
385 struct PotentiallySealed<int> sealed { };
387 void is_final()
389 { int arr[T(__is_final(SealedClass))]; }
390 { int arr[T(__is_final(PotentiallySealed<float*>))]; }
391 { int arr[T(__is_final(PotentiallySealed<int>))]; }
392 { int arr[T(__is_final(FinalClass))]; }
393 { int arr[T(__is_final(PotentiallyFinal<float*>))]; }
394 { int arr[T(__is_final(PotentiallyFinal<int>))]; }
396 { int arr[F(__is_final(int))]; }
397 { int arr[F(__is_final(Union))]; }
398 { int arr[F(__is_final(Int))]; }
399 { int arr[F(__is_final(IntAr))]; }
400 { int arr[F(__is_final(UnionAr))]; }
401 { int arr[F(__is_final(Derives))]; }
402 { int arr[F(__is_final(ClassType))]; }
403 { int arr[F(__is_final(cvoid))]; }
404 { int arr[F(__is_final(IntArNB))]; }
405 { int arr[F(__is_final(HasAnonymousUnion))]; }
406 { int arr[F(__is_final(PotentiallyFinal<float>))]; }
407 { int arr[F(__is_final(PotentiallySealed<float>))]; }
410 void is_sealed()
412 { int arr[T(__is_sealed(SealedClass))]; }
413 { int arr[T(__is_sealed(PotentiallySealed<float*>))]; }
414 { int arr[T(__is_sealed(PotentiallySealed<int>))]; }
415 { int arr[T(__is_sealed(FinalClass))]; }
416 { int arr[T(__is_sealed(PotentiallyFinal<float*>))]; }
417 { int arr[T(__is_sealed(PotentiallyFinal<int>))]; }
419 { int arr[F(__is_sealed(int))]; }
420 { int arr[F(__is_sealed(Union))]; }
421 { int arr[F(__is_sealed(Int))]; }
422 { int arr[F(__is_sealed(IntAr))]; }
423 { int arr[F(__is_sealed(UnionAr))]; }
424 { int arr[F(__is_sealed(Derives))]; }
425 { int arr[F(__is_sealed(ClassType))]; }
426 { int arr[F(__is_sealed(cvoid))]; }
427 { int arr[F(__is_sealed(IntArNB))]; }
428 { int arr[F(__is_sealed(HasAnonymousUnion))]; }
429 { int arr[F(__is_sealed(PotentiallyFinal<float>))]; }
430 { int arr[F(__is_sealed(PotentiallySealed<float>))]; }
433 typedef HasVirt Polymorph;
434 struct InheritPolymorph : Polymorph {};
436 void is_polymorphic()
438 { int arr[T(__is_polymorphic(Polymorph))]; }
439 { int arr[T(__is_polymorphic(InheritPolymorph))]; }
441 { int arr[F(__is_polymorphic(int))]; }
442 { int arr[F(__is_polymorphic(Union))]; }
443 { int arr[F(__is_polymorphic(IncompleteUnion))]; }
444 { int arr[F(__is_polymorphic(Int))]; }
445 { int arr[F(__is_polymorphic(IntAr))]; }
446 { int arr[F(__is_polymorphic(UnionAr))]; }
447 { int arr[F(__is_polymorphic(Derives))]; }
448 { int arr[F(__is_polymorphic(ClassType))]; }
449 { int arr[F(__is_polymorphic(Enum))]; }
450 { int arr[F(__is_polymorphic(cvoid))]; }
451 { int arr[F(__is_polymorphic(IntArNB))]; }
454 void is_integral()
456 int t01[T(__is_integral(bool))];
457 int t02[T(__is_integral(char))];
458 int t03[T(__is_integral(signed char))];
459 int t04[T(__is_integral(unsigned char))];
460 //int t05[T(__is_integral(char16_t))];
461 //int t06[T(__is_integral(char32_t))];
462 int t07[T(__is_integral(wchar_t))];
463 int t08[T(__is_integral(short))];
464 int t09[T(__is_integral(unsigned short))];
465 int t10[T(__is_integral(int))];
466 int t11[T(__is_integral(unsigned int))];
467 int t12[T(__is_integral(long))];
468 int t13[T(__is_integral(unsigned long))];
470 int t21[F(__is_integral(float))];
471 int t22[F(__is_integral(double))];
472 int t23[F(__is_integral(long double))];
473 int t24[F(__is_integral(Union))];
474 int t25[F(__is_integral(UnionAr))];
475 int t26[F(__is_integral(Derives))];
476 int t27[F(__is_integral(ClassType))];
477 int t28[F(__is_integral(Enum))];
478 int t29[F(__is_integral(void))];
479 int t30[F(__is_integral(cvoid))];
480 int t31[F(__is_integral(IntArNB))];
483 void is_floating_point()
485 int t01[T(__is_floating_point(float))];
486 int t02[T(__is_floating_point(double))];
487 int t03[T(__is_floating_point(long double))];
489 int t11[F(__is_floating_point(bool))];
490 int t12[F(__is_floating_point(char))];
491 int t13[F(__is_floating_point(signed char))];
492 int t14[F(__is_floating_point(unsigned char))];
493 //int t15[F(__is_floating_point(char16_t))];
494 //int t16[F(__is_floating_point(char32_t))];
495 int t17[F(__is_floating_point(wchar_t))];
496 int t18[F(__is_floating_point(short))];
497 int t19[F(__is_floating_point(unsigned short))];
498 int t20[F(__is_floating_point(int))];
499 int t21[F(__is_floating_point(unsigned int))];
500 int t22[F(__is_floating_point(long))];
501 int t23[F(__is_floating_point(unsigned long))];
502 int t24[F(__is_floating_point(Union))];
503 int t25[F(__is_floating_point(UnionAr))];
504 int t26[F(__is_floating_point(Derives))];
505 int t27[F(__is_floating_point(ClassType))];
506 int t28[F(__is_floating_point(Enum))];
507 int t29[F(__is_floating_point(void))];
508 int t30[F(__is_floating_point(cvoid))];
509 int t31[F(__is_floating_point(IntArNB))];
512 template <class T>
513 struct AggregateTemplate {
514 T value;
517 template <class T>
518 struct NonAggregateTemplate {
519 T value;
520 NonAggregateTemplate();
523 void is_aggregate()
525 constexpr bool TrueAfterCpp11 = __cplusplus > 201103L;
526 constexpr bool TrueAfterCpp14 = __cplusplus > 201402L;
528 __is_aggregate(AnIncompleteType); // expected-error {{incomplete type}}
529 __is_aggregate(AnIncompleteType[]); // expected-error {{incomplete type}}
530 __is_aggregate(AnIncompleteType[1]); // expected-error {{incomplete type}}
531 __is_aggregate(AnIncompleteTypeAr); // expected-error {{incomplete type}}
532 __is_aggregate(AnIncompleteTypeArNB); // expected-error {{incomplete type}}
533 __is_aggregate(AnIncompleteTypeArMB); // expected-error {{incomplete type}}
534 __is_aggregate(IncompleteUnion); // expected-error {{incomplete type}}
536 static_assert(!__is_aggregate(NonPOD), "");
537 static_assert(__is_aggregate(NonPODAr), "");
538 static_assert(__is_aggregate(NonPODArNB), "");
539 static_assert(__is_aggregate(NonPODArMB), "");
541 static_assert(!__is_aggregate(Enum), "");
542 static_assert(__is_aggregate(POD), "");
543 static_assert(__is_aggregate(Empty), "");
544 static_assert(__is_aggregate(EmptyAr), "");
545 static_assert(__is_aggregate(EmptyArNB), "");
546 static_assert(__is_aggregate(EmptyArMB), "");
547 static_assert(!__is_aggregate(void), "");
548 static_assert(!__is_aggregate(const volatile void), "");
549 static_assert(!__is_aggregate(int), "");
550 static_assert(__is_aggregate(IntAr), "");
551 static_assert(__is_aggregate(IntArNB), "");
552 static_assert(__is_aggregate(EmptyUnion), "");
553 static_assert(__is_aggregate(Union), "");
554 static_assert(__is_aggregate(Statics), "");
555 static_assert(__is_aggregate(HasFunc), "");
556 static_assert(__is_aggregate(HasOp), "");
557 static_assert(__is_aggregate(HasAssign), "");
558 static_assert(__is_aggregate(HasAnonymousUnion), "");
560 static_assert(__is_aggregate(Derives) == TrueAfterCpp14, "");
561 static_assert(__is_aggregate(DerivesAr), "");
562 static_assert(__is_aggregate(DerivesArNB), "");
563 static_assert(!__is_aggregate(HasCons), "");
564 static_assert(__is_aggregate(HasDefaultCons), "");
565 static_assert(!__is_aggregate(HasExplicitDefaultCons), "");
566 static_assert(!__is_aggregate(HasInheritedCons), "");
567 static_assert(__is_aggregate(HasNoInheritedCons) == TrueAfterCpp14, "");
568 static_assert(__is_aggregate(HasCopyAssign), "");
569 static_assert(!__is_aggregate(NonTrivialDefault), "");
570 static_assert(__is_aggregate(HasDest), "");
571 static_assert(!__is_aggregate(HasPriv), "");
572 static_assert(!__is_aggregate(HasProt), "");
573 static_assert(__is_aggregate(HasRefAggregate), "");
574 static_assert(__is_aggregate(HasNonPOD), "");
575 static_assert(!__is_aggregate(HasVirt), "");
576 static_assert(__is_aggregate(VirtAr), "");
577 static_assert(__is_aggregate(HasInClassInit) == TrueAfterCpp11, "");
578 static_assert(!__is_aggregate(HasPrivateBase), "");
579 static_assert(!__is_aggregate(HasProtectedBase), "");
580 static_assert(!__is_aggregate(HasVirtBase), "");
582 static_assert(__is_aggregate(AggregateTemplate<int>), "");
583 static_assert(!__is_aggregate(NonAggregateTemplate<int>), "");
585 static_assert(__is_aggregate(Vector), ""); // Extension supported by GCC and Clang
586 static_assert(__is_aggregate(VectorExt), "");
587 static_assert(__is_aggregate(ComplexInt), "");
588 static_assert(__is_aggregate(ComplexFloat), "");
591 void is_arithmetic()
593 int t01[T(__is_arithmetic(float))];
594 int t02[T(__is_arithmetic(double))];
595 int t03[T(__is_arithmetic(long double))];
596 int t11[T(__is_arithmetic(bool))];
597 int t12[T(__is_arithmetic(char))];
598 int t13[T(__is_arithmetic(signed char))];
599 int t14[T(__is_arithmetic(unsigned char))];
600 //int t15[T(__is_arithmetic(char16_t))];
601 //int t16[T(__is_arithmetic(char32_t))];
602 int t17[T(__is_arithmetic(wchar_t))];
603 int t18[T(__is_arithmetic(short))];
604 int t19[T(__is_arithmetic(unsigned short))];
605 int t20[T(__is_arithmetic(int))];
606 int t21[T(__is_arithmetic(unsigned int))];
607 int t22[T(__is_arithmetic(long))];
608 int t23[T(__is_arithmetic(unsigned long))];
610 int t24[F(__is_arithmetic(Union))];
611 int t25[F(__is_arithmetic(UnionAr))];
612 int t26[F(__is_arithmetic(Derives))];
613 int t27[F(__is_arithmetic(ClassType))];
614 int t28[F(__is_arithmetic(Enum))];
615 int t29[F(__is_arithmetic(void))];
616 int t30[F(__is_arithmetic(cvoid))];
617 int t31[F(__is_arithmetic(IntArNB))];
620 void is_complete_type()
622 int t01[T(__is_complete_type(float))];
623 int t02[T(__is_complete_type(double))];
624 int t03[T(__is_complete_type(long double))];
625 int t11[T(__is_complete_type(bool))];
626 int t12[T(__is_complete_type(char))];
627 int t13[T(__is_complete_type(signed char))];
628 int t14[T(__is_complete_type(unsigned char))];
629 //int t15[T(__is_complete_type(char16_t))];
630 //int t16[T(__is_complete_type(char32_t))];
631 int t17[T(__is_complete_type(wchar_t))];
632 int t18[T(__is_complete_type(short))];
633 int t19[T(__is_complete_type(unsigned short))];
634 int t20[T(__is_complete_type(int))];
635 int t21[T(__is_complete_type(unsigned int))];
636 int t22[T(__is_complete_type(long))];
637 int t23[T(__is_complete_type(unsigned long))];
638 int t24[T(__is_complete_type(ACompleteType))];
640 int t30[F(__is_complete_type(AnIncompleteType))];
643 void is_void()
645 int t01[T(__is_void(void))];
646 int t02[T(__is_void(cvoid))];
648 int t10[F(__is_void(float))];
649 int t11[F(__is_void(double))];
650 int t12[F(__is_void(long double))];
651 int t13[F(__is_void(bool))];
652 int t14[F(__is_void(char))];
653 int t15[F(__is_void(signed char))];
654 int t16[F(__is_void(unsigned char))];
655 int t17[F(__is_void(wchar_t))];
656 int t18[F(__is_void(short))];
657 int t19[F(__is_void(unsigned short))];
658 int t20[F(__is_void(int))];
659 int t21[F(__is_void(unsigned int))];
660 int t22[F(__is_void(long))];
661 int t23[F(__is_void(unsigned long))];
662 int t24[F(__is_void(Union))];
663 int t25[F(__is_void(UnionAr))];
664 int t26[F(__is_void(Derives))];
665 int t27[F(__is_void(ClassType))];
666 int t28[F(__is_void(Enum))];
667 int t29[F(__is_void(IntArNB))];
668 int t30[F(__is_void(void*))];
669 int t31[F(__is_void(cvoid*))];
672 void is_array()
674 int t01[T(__is_array(IntAr))];
675 int t02[T(__is_array(IntArNB))];
676 int t03[T(__is_array(UnionAr))];
678 int t10[F(__is_array(void))];
679 int t11[F(__is_array(cvoid))];
680 int t12[F(__is_array(float))];
681 int t13[F(__is_array(double))];
682 int t14[F(__is_array(long double))];
683 int t15[F(__is_array(bool))];
684 int t16[F(__is_array(char))];
685 int t17[F(__is_array(signed char))];
686 int t18[F(__is_array(unsigned char))];
687 int t19[F(__is_array(wchar_t))];
688 int t20[F(__is_array(short))];
689 int t21[F(__is_array(unsigned short))];
690 int t22[F(__is_array(int))];
691 int t23[F(__is_array(unsigned int))];
692 int t24[F(__is_array(long))];
693 int t25[F(__is_array(unsigned long))];
694 int t26[F(__is_array(Union))];
695 int t27[F(__is_array(Derives))];
696 int t28[F(__is_array(ClassType))];
697 int t29[F(__is_array(Enum))];
698 int t30[F(__is_array(void*))];
699 int t31[F(__is_array(cvoid*))];
702 template <typename T> void tmpl_func(T&) {}
704 template <typename T> struct type_wrapper {
705 typedef T type;
706 typedef T* ptrtype;
707 typedef T& reftype;
710 void is_function()
712 int t01[T(__is_function(type_wrapper<void(void)>::type))];
713 int t02[T(__is_function(typeof(tmpl_func<int>)))];
715 typedef void (*ptr_to_func_type)(void);
717 int t10[F(__is_function(void))];
718 int t11[F(__is_function(cvoid))];
719 int t12[F(__is_function(float))];
720 int t13[F(__is_function(double))];
721 int t14[F(__is_function(long double))];
722 int t15[F(__is_function(bool))];
723 int t16[F(__is_function(char))];
724 int t17[F(__is_function(signed char))];
725 int t18[F(__is_function(unsigned char))];
726 int t19[F(__is_function(wchar_t))];
727 int t20[F(__is_function(short))];
728 int t21[F(__is_function(unsigned short))];
729 int t22[F(__is_function(int))];
730 int t23[F(__is_function(unsigned int))];
731 int t24[F(__is_function(long))];
732 int t25[F(__is_function(unsigned long))];
733 int t26[F(__is_function(Union))];
734 int t27[F(__is_function(Derives))];
735 int t28[F(__is_function(ClassType))];
736 int t29[F(__is_function(Enum))];
737 int t30[F(__is_function(void*))];
738 int t31[F(__is_function(cvoid*))];
739 int t32[F(__is_function(void(*)()))];
740 int t33[F(__is_function(ptr_to_func_type))];
741 int t34[F(__is_function(type_wrapper<void(void)>::ptrtype))];
742 int t35[F(__is_function(type_wrapper<void(void)>::reftype))];
745 void is_reference()
747 int t01[T(__is_reference(int&))];
748 int t02[T(__is_reference(const int&))];
749 int t03[T(__is_reference(void *&))];
751 int t10[F(__is_reference(int))];
752 int t11[F(__is_reference(const int))];
753 int t12[F(__is_reference(void *))];
756 void is_lvalue_reference()
758 int t01[T(__is_lvalue_reference(int&))];
759 int t02[T(__is_lvalue_reference(void *&))];
760 int t03[T(__is_lvalue_reference(const int&))];
761 int t04[T(__is_lvalue_reference(void * const &))];
763 int t10[F(__is_lvalue_reference(int))];
764 int t11[F(__is_lvalue_reference(const int))];
765 int t12[F(__is_lvalue_reference(void *))];
768 #if __has_feature(cxx_rvalue_references)
770 void is_rvalue_reference()
772 int t01[T(__is_rvalue_reference(const int&&))];
773 int t02[T(__is_rvalue_reference(void * const &&))];
775 int t10[F(__is_rvalue_reference(int&))];
776 int t11[F(__is_rvalue_reference(void *&))];
777 int t12[F(__is_rvalue_reference(const int&))];
778 int t13[F(__is_rvalue_reference(void * const &))];
779 int t14[F(__is_rvalue_reference(int))];
780 int t15[F(__is_rvalue_reference(const int))];
781 int t16[F(__is_rvalue_reference(void *))];
784 #endif
786 void is_fundamental()
788 int t01[T(__is_fundamental(float))];
789 int t02[T(__is_fundamental(double))];
790 int t03[T(__is_fundamental(long double))];
791 int t11[T(__is_fundamental(bool))];
792 int t12[T(__is_fundamental(char))];
793 int t13[T(__is_fundamental(signed char))];
794 int t14[T(__is_fundamental(unsigned char))];
795 //int t15[T(__is_fundamental(char16_t))];
796 //int t16[T(__is_fundamental(char32_t))];
797 int t17[T(__is_fundamental(wchar_t))];
798 int t18[T(__is_fundamental(short))];
799 int t19[T(__is_fundamental(unsigned short))];
800 int t20[T(__is_fundamental(int))];
801 int t21[T(__is_fundamental(unsigned int))];
802 int t22[T(__is_fundamental(long))];
803 int t23[T(__is_fundamental(unsigned long))];
804 int t24[T(__is_fundamental(void))];
805 int t25[T(__is_fundamental(cvoid))];
806 int t26[T(__is_fundamental(decltype(nullptr)))];
808 int t30[F(__is_fundamental(Union))];
809 int t31[F(__is_fundamental(UnionAr))];
810 int t32[F(__is_fundamental(Derives))];
811 int t33[F(__is_fundamental(ClassType))];
812 int t34[F(__is_fundamental(Enum))];
813 int t35[F(__is_fundamental(IntArNB))];
816 void is_object()
818 int t01[T(__is_object(int))];
819 int t02[T(__is_object(int *))];
820 int t03[T(__is_object(void *))];
821 int t04[T(__is_object(Union))];
822 int t05[T(__is_object(UnionAr))];
823 int t06[T(__is_object(ClassType))];
824 int t07[T(__is_object(Enum))];
826 int t10[F(__is_object(type_wrapper<void(void)>::type))];
827 int t11[F(__is_object(int&))];
828 int t12[F(__is_object(void))];
831 void is_scalar()
833 int t01[T(__is_scalar(float))];
834 int t02[T(__is_scalar(double))];
835 int t03[T(__is_scalar(long double))];
836 int t04[T(__is_scalar(bool))];
837 int t05[T(__is_scalar(char))];
838 int t06[T(__is_scalar(signed char))];
839 int t07[T(__is_scalar(unsigned char))];
840 int t08[T(__is_scalar(wchar_t))];
841 int t09[T(__is_scalar(short))];
842 int t10[T(__is_scalar(unsigned short))];
843 int t11[T(__is_scalar(int))];
844 int t12[T(__is_scalar(unsigned int))];
845 int t13[T(__is_scalar(long))];
846 int t14[T(__is_scalar(unsigned long))];
847 int t15[T(__is_scalar(Enum))];
848 int t16[T(__is_scalar(void*))];
849 int t17[T(__is_scalar(cvoid*))];
851 int t20[F(__is_scalar(void))];
852 int t21[F(__is_scalar(cvoid))];
853 int t22[F(__is_scalar(Union))];
854 int t23[F(__is_scalar(UnionAr))];
855 int t24[F(__is_scalar(Derives))];
856 int t25[F(__is_scalar(ClassType))];
857 int t26[F(__is_scalar(IntArNB))];
860 struct StructWithMembers {
861 int member;
862 void method() {}
865 void is_compound()
867 int t01[T(__is_compound(void*))];
868 int t02[T(__is_compound(cvoid*))];
869 int t03[T(__is_compound(void (*)()))];
870 int t04[T(__is_compound(int StructWithMembers::*))];
871 int t05[T(__is_compound(void (StructWithMembers::*)()))];
872 int t06[T(__is_compound(int&))];
873 int t07[T(__is_compound(Union))];
874 int t08[T(__is_compound(UnionAr))];
875 int t09[T(__is_compound(Derives))];
876 int t10[T(__is_compound(ClassType))];
877 int t11[T(__is_compound(IntArNB))];
878 int t12[T(__is_compound(Enum))];
880 int t20[F(__is_compound(float))];
881 int t21[F(__is_compound(double))];
882 int t22[F(__is_compound(long double))];
883 int t23[F(__is_compound(bool))];
884 int t24[F(__is_compound(char))];
885 int t25[F(__is_compound(signed char))];
886 int t26[F(__is_compound(unsigned char))];
887 int t27[F(__is_compound(wchar_t))];
888 int t28[F(__is_compound(short))];
889 int t29[F(__is_compound(unsigned short))];
890 int t30[F(__is_compound(int))];
891 int t31[F(__is_compound(unsigned int))];
892 int t32[F(__is_compound(long))];
893 int t33[F(__is_compound(unsigned long))];
894 int t34[F(__is_compound(void))];
895 int t35[F(__is_compound(cvoid))];
898 void is_pointer()
900 StructWithMembers x;
902 int t01[T(__is_pointer(void*))];
903 int t02[T(__is_pointer(cvoid*))];
904 int t03[T(__is_pointer(cvoid*))];
905 int t04[T(__is_pointer(char*))];
906 int t05[T(__is_pointer(int*))];
907 int t06[T(__is_pointer(int**))];
908 int t07[T(__is_pointer(ClassType*))];
909 int t08[T(__is_pointer(Derives*))];
910 int t09[T(__is_pointer(Enum*))];
911 int t10[T(__is_pointer(IntArNB*))];
912 int t11[T(__is_pointer(Union*))];
913 int t12[T(__is_pointer(UnionAr*))];
914 int t13[T(__is_pointer(StructWithMembers*))];
915 int t14[T(__is_pointer(void (*)()))];
917 int t20[F(__is_pointer(void))];
918 int t21[F(__is_pointer(cvoid))];
919 int t22[F(__is_pointer(cvoid))];
920 int t23[F(__is_pointer(char))];
921 int t24[F(__is_pointer(int))];
922 int t25[F(__is_pointer(int))];
923 int t26[F(__is_pointer(ClassType))];
924 int t27[F(__is_pointer(Derives))];
925 int t28[F(__is_pointer(Enum))];
926 int t29[F(__is_pointer(IntArNB))];
927 int t30[F(__is_pointer(Union))];
928 int t31[F(__is_pointer(UnionAr))];
929 int t32[F(__is_pointer(StructWithMembers))];
930 int t33[F(__is_pointer(int StructWithMembers::*))];
931 int t34[F(__is_pointer(void (StructWithMembers::*) ()))];
934 void is_member_object_pointer()
936 StructWithMembers x;
938 int t01[T(__is_member_object_pointer(int StructWithMembers::*))];
940 int t10[F(__is_member_object_pointer(void (StructWithMembers::*) ()))];
941 int t11[F(__is_member_object_pointer(void*))];
942 int t12[F(__is_member_object_pointer(cvoid*))];
943 int t13[F(__is_member_object_pointer(cvoid*))];
944 int t14[F(__is_member_object_pointer(char*))];
945 int t15[F(__is_member_object_pointer(int*))];
946 int t16[F(__is_member_object_pointer(int**))];
947 int t17[F(__is_member_object_pointer(ClassType*))];
948 int t18[F(__is_member_object_pointer(Derives*))];
949 int t19[F(__is_member_object_pointer(Enum*))];
950 int t20[F(__is_member_object_pointer(IntArNB*))];
951 int t21[F(__is_member_object_pointer(Union*))];
952 int t22[F(__is_member_object_pointer(UnionAr*))];
953 int t23[F(__is_member_object_pointer(StructWithMembers*))];
954 int t24[F(__is_member_object_pointer(void))];
955 int t25[F(__is_member_object_pointer(cvoid))];
956 int t26[F(__is_member_object_pointer(cvoid))];
957 int t27[F(__is_member_object_pointer(char))];
958 int t28[F(__is_member_object_pointer(int))];
959 int t29[F(__is_member_object_pointer(int))];
960 int t30[F(__is_member_object_pointer(ClassType))];
961 int t31[F(__is_member_object_pointer(Derives))];
962 int t32[F(__is_member_object_pointer(Enum))];
963 int t33[F(__is_member_object_pointer(IntArNB))];
964 int t34[F(__is_member_object_pointer(Union))];
965 int t35[F(__is_member_object_pointer(UnionAr))];
966 int t36[F(__is_member_object_pointer(StructWithMembers))];
967 int t37[F(__is_member_object_pointer(void (*)()))];
970 void is_member_function_pointer()
972 StructWithMembers x;
974 int t01[T(__is_member_function_pointer(void (StructWithMembers::*) ()))];
976 int t10[F(__is_member_function_pointer(int StructWithMembers::*))];
977 int t11[F(__is_member_function_pointer(void*))];
978 int t12[F(__is_member_function_pointer(cvoid*))];
979 int t13[F(__is_member_function_pointer(cvoid*))];
980 int t14[F(__is_member_function_pointer(char*))];
981 int t15[F(__is_member_function_pointer(int*))];
982 int t16[F(__is_member_function_pointer(int**))];
983 int t17[F(__is_member_function_pointer(ClassType*))];
984 int t18[F(__is_member_function_pointer(Derives*))];
985 int t19[F(__is_member_function_pointer(Enum*))];
986 int t20[F(__is_member_function_pointer(IntArNB*))];
987 int t21[F(__is_member_function_pointer(Union*))];
988 int t22[F(__is_member_function_pointer(UnionAr*))];
989 int t23[F(__is_member_function_pointer(StructWithMembers*))];
990 int t24[F(__is_member_function_pointer(void))];
991 int t25[F(__is_member_function_pointer(cvoid))];
992 int t26[F(__is_member_function_pointer(cvoid))];
993 int t27[F(__is_member_function_pointer(char))];
994 int t28[F(__is_member_function_pointer(int))];
995 int t29[F(__is_member_function_pointer(int))];
996 int t30[F(__is_member_function_pointer(ClassType))];
997 int t31[F(__is_member_function_pointer(Derives))];
998 int t32[F(__is_member_function_pointer(Enum))];
999 int t33[F(__is_member_function_pointer(IntArNB))];
1000 int t34[F(__is_member_function_pointer(Union))];
1001 int t35[F(__is_member_function_pointer(UnionAr))];
1002 int t36[F(__is_member_function_pointer(StructWithMembers))];
1003 int t37[F(__is_member_function_pointer(void (*)()))];
1006 void is_member_pointer()
1008 StructWithMembers x;
1010 int t01[T(__is_member_pointer(int StructWithMembers::*))];
1011 int t02[T(__is_member_pointer(void (StructWithMembers::*) ()))];
1013 int t10[F(__is_member_pointer(void*))];
1014 int t11[F(__is_member_pointer(cvoid*))];
1015 int t12[F(__is_member_pointer(cvoid*))];
1016 int t13[F(__is_member_pointer(char*))];
1017 int t14[F(__is_member_pointer(int*))];
1018 int t15[F(__is_member_pointer(int**))];
1019 int t16[F(__is_member_pointer(ClassType*))];
1020 int t17[F(__is_member_pointer(Derives*))];
1021 int t18[F(__is_member_pointer(Enum*))];
1022 int t19[F(__is_member_pointer(IntArNB*))];
1023 int t20[F(__is_member_pointer(Union*))];
1024 int t21[F(__is_member_pointer(UnionAr*))];
1025 int t22[F(__is_member_pointer(StructWithMembers*))];
1026 int t23[F(__is_member_pointer(void))];
1027 int t24[F(__is_member_pointer(cvoid))];
1028 int t25[F(__is_member_pointer(cvoid))];
1029 int t26[F(__is_member_pointer(char))];
1030 int t27[F(__is_member_pointer(int))];
1031 int t28[F(__is_member_pointer(int))];
1032 int t29[F(__is_member_pointer(ClassType))];
1033 int t30[F(__is_member_pointer(Derives))];
1034 int t31[F(__is_member_pointer(Enum))];
1035 int t32[F(__is_member_pointer(IntArNB))];
1036 int t33[F(__is_member_pointer(Union))];
1037 int t34[F(__is_member_pointer(UnionAr))];
1038 int t35[F(__is_member_pointer(StructWithMembers))];
1039 int t36[F(__is_member_pointer(void (*)()))];
1042 void is_const()
1044 int t01[T(__is_const(cvoid))];
1045 int t02[T(__is_const(const char))];
1046 int t03[T(__is_const(const int))];
1047 int t04[T(__is_const(const long))];
1048 int t05[T(__is_const(const short))];
1049 int t06[T(__is_const(const signed char))];
1050 int t07[T(__is_const(const wchar_t))];
1051 int t08[T(__is_const(const bool))];
1052 int t09[T(__is_const(const float))];
1053 int t10[T(__is_const(const double))];
1054 int t11[T(__is_const(const long double))];
1055 int t12[T(__is_const(const unsigned char))];
1056 int t13[T(__is_const(const unsigned int))];
1057 int t14[T(__is_const(const unsigned long long))];
1058 int t15[T(__is_const(const unsigned long))];
1059 int t16[T(__is_const(const unsigned short))];
1060 int t17[T(__is_const(const void))];
1061 int t18[T(__is_const(const ClassType))];
1062 int t19[T(__is_const(const Derives))];
1063 int t20[T(__is_const(const Enum))];
1064 int t21[T(__is_const(const IntArNB))];
1065 int t22[T(__is_const(const Union))];
1066 int t23[T(__is_const(const UnionAr))];
1068 int t30[F(__is_const(char))];
1069 int t31[F(__is_const(int))];
1070 int t32[F(__is_const(long))];
1071 int t33[F(__is_const(short))];
1072 int t34[F(__is_const(signed char))];
1073 int t35[F(__is_const(wchar_t))];
1074 int t36[F(__is_const(bool))];
1075 int t37[F(__is_const(float))];
1076 int t38[F(__is_const(double))];
1077 int t39[F(__is_const(long double))];
1078 int t40[F(__is_const(unsigned char))];
1079 int t41[F(__is_const(unsigned int))];
1080 int t42[F(__is_const(unsigned long long))];
1081 int t43[F(__is_const(unsigned long))];
1082 int t44[F(__is_const(unsigned short))];
1083 int t45[F(__is_const(void))];
1084 int t46[F(__is_const(ClassType))];
1085 int t47[F(__is_const(Derives))];
1086 int t48[F(__is_const(Enum))];
1087 int t49[F(__is_const(IntArNB))];
1088 int t50[F(__is_const(Union))];
1089 int t51[F(__is_const(UnionAr))];
1092 void is_volatile()
1094 int t02[T(__is_volatile(volatile char))];
1095 int t03[T(__is_volatile(volatile int))];
1096 int t04[T(__is_volatile(volatile long))];
1097 int t05[T(__is_volatile(volatile short))];
1098 int t06[T(__is_volatile(volatile signed char))];
1099 int t07[T(__is_volatile(volatile wchar_t))];
1100 int t08[T(__is_volatile(volatile bool))];
1101 int t09[T(__is_volatile(volatile float))];
1102 int t10[T(__is_volatile(volatile double))];
1103 int t11[T(__is_volatile(volatile long double))];
1104 int t12[T(__is_volatile(volatile unsigned char))];
1105 int t13[T(__is_volatile(volatile unsigned int))];
1106 int t14[T(__is_volatile(volatile unsigned long long))];
1107 int t15[T(__is_volatile(volatile unsigned long))];
1108 int t16[T(__is_volatile(volatile unsigned short))];
1109 int t17[T(__is_volatile(volatile void))];
1110 int t18[T(__is_volatile(volatile ClassType))];
1111 int t19[T(__is_volatile(volatile Derives))];
1112 int t20[T(__is_volatile(volatile Enum))];
1113 int t21[T(__is_volatile(volatile IntArNB))];
1114 int t22[T(__is_volatile(volatile Union))];
1115 int t23[T(__is_volatile(volatile UnionAr))];
1117 int t30[F(__is_volatile(char))];
1118 int t31[F(__is_volatile(int))];
1119 int t32[F(__is_volatile(long))];
1120 int t33[F(__is_volatile(short))];
1121 int t34[F(__is_volatile(signed char))];
1122 int t35[F(__is_volatile(wchar_t))];
1123 int t36[F(__is_volatile(bool))];
1124 int t37[F(__is_volatile(float))];
1125 int t38[F(__is_volatile(double))];
1126 int t39[F(__is_volatile(long double))];
1127 int t40[F(__is_volatile(unsigned char))];
1128 int t41[F(__is_volatile(unsigned int))];
1129 int t42[F(__is_volatile(unsigned long long))];
1130 int t43[F(__is_volatile(unsigned long))];
1131 int t44[F(__is_volatile(unsigned short))];
1132 int t45[F(__is_volatile(void))];
1133 int t46[F(__is_volatile(ClassType))];
1134 int t47[F(__is_volatile(Derives))];
1135 int t48[F(__is_volatile(Enum))];
1136 int t49[F(__is_volatile(IntArNB))];
1137 int t50[F(__is_volatile(Union))];
1138 int t51[F(__is_volatile(UnionAr))];
1141 struct TrivialStruct {
1142 int member;
1145 struct NonTrivialStruct {
1146 int member;
1147 NonTrivialStruct() {
1148 member = 0;
1152 struct SuperNonTrivialStruct {
1153 SuperNonTrivialStruct() { }
1154 ~SuperNonTrivialStruct() { }
1157 struct NonTCStruct {
1158 NonTCStruct(const NonTCStruct&) {}
1161 struct AllDefaulted {
1162 AllDefaulted() = default;
1163 AllDefaulted(const AllDefaulted &) = default;
1164 AllDefaulted(AllDefaulted &&) = default;
1165 AllDefaulted &operator=(const AllDefaulted &) = default;
1166 AllDefaulted &operator=(AllDefaulted &&) = default;
1167 ~AllDefaulted() = default;
1170 struct NoDefaultMoveAssignDueToUDCopyCtor {
1171 NoDefaultMoveAssignDueToUDCopyCtor(const NoDefaultMoveAssignDueToUDCopyCtor&);
1174 struct NoDefaultMoveAssignDueToUDCopyAssign {
1175 NoDefaultMoveAssignDueToUDCopyAssign& operator=(
1176 const NoDefaultMoveAssignDueToUDCopyAssign&);
1179 struct NoDefaultMoveAssignDueToDtor {
1180 ~NoDefaultMoveAssignDueToDtor();
1183 struct AllDeleted {
1184 AllDeleted() = delete;
1185 AllDeleted(const AllDeleted &) = delete;
1186 AllDeleted(AllDeleted &&) = delete;
1187 AllDeleted &operator=(const AllDeleted &) = delete;
1188 AllDeleted &operator=(AllDeleted &&) = delete;
1189 ~AllDeleted() = delete;
1192 struct ExtDefaulted {
1193 ExtDefaulted();
1194 ExtDefaulted(const ExtDefaulted &);
1195 ExtDefaulted(ExtDefaulted &&);
1196 ExtDefaulted &operator=(const ExtDefaulted &);
1197 ExtDefaulted &operator=(ExtDefaulted &&);
1198 ~ExtDefaulted();
1201 // Despite being defaulted, these functions are not trivial.
1202 ExtDefaulted::ExtDefaulted() = default;
1203 ExtDefaulted::ExtDefaulted(const ExtDefaulted &) = default;
1204 ExtDefaulted::ExtDefaulted(ExtDefaulted &&) = default;
1205 ExtDefaulted &ExtDefaulted::operator=(const ExtDefaulted &) = default;
1206 ExtDefaulted &ExtDefaulted::operator=(ExtDefaulted &&) = default;
1207 ExtDefaulted::~ExtDefaulted() = default;
1209 void is_trivial2()
1211 int t01[T(__is_trivial(char))];
1212 int t02[T(__is_trivial(int))];
1213 int t03[T(__is_trivial(long))];
1214 int t04[T(__is_trivial(short))];
1215 int t05[T(__is_trivial(signed char))];
1216 int t06[T(__is_trivial(wchar_t))];
1217 int t07[T(__is_trivial(bool))];
1218 int t08[T(__is_trivial(float))];
1219 int t09[T(__is_trivial(double))];
1220 int t10[T(__is_trivial(long double))];
1221 int t11[T(__is_trivial(unsigned char))];
1222 int t12[T(__is_trivial(unsigned int))];
1223 int t13[T(__is_trivial(unsigned long long))];
1224 int t14[T(__is_trivial(unsigned long))];
1225 int t15[T(__is_trivial(unsigned short))];
1226 int t16[T(__is_trivial(ClassType))];
1227 int t17[T(__is_trivial(Derives))];
1228 int t18[T(__is_trivial(Enum))];
1229 int t19[T(__is_trivial(IntAr))];
1230 int t20[T(__is_trivial(Union))];
1231 int t21[T(__is_trivial(UnionAr))];
1232 int t22[T(__is_trivial(TrivialStruct))];
1233 int t23[T(__is_trivial(AllDefaulted))];
1234 int t24[T(__is_trivial(AllDeleted))];
1236 int t30[F(__is_trivial(void))];
1237 int t31[F(__is_trivial(NonTrivialStruct))];
1238 int t32[F(__is_trivial(SuperNonTrivialStruct))];
1239 int t33[F(__is_trivial(NonTCStruct))];
1240 int t34[F(__is_trivial(ExtDefaulted))];
1242 int t40[T(__is_trivial(ACompleteType))];
1243 int t41[F(__is_trivial(AnIncompleteType))]; // expected-error {{incomplete type}}
1244 int t42[F(__is_trivial(AnIncompleteType[]))]; // expected-error {{incomplete type}}
1245 int t43[F(__is_trivial(AnIncompleteType[1]))]; // expected-error {{incomplete type}}
1246 int t44[F(__is_trivial(void))];
1247 int t45[F(__is_trivial(const volatile void))];
1250 void is_trivially_copyable2()
1252 int t01[T(__is_trivially_copyable(char))];
1253 int t02[T(__is_trivially_copyable(int))];
1254 int t03[T(__is_trivially_copyable(long))];
1255 int t04[T(__is_trivially_copyable(short))];
1256 int t05[T(__is_trivially_copyable(signed char))];
1257 int t06[T(__is_trivially_copyable(wchar_t))];
1258 int t07[T(__is_trivially_copyable(bool))];
1259 int t08[T(__is_trivially_copyable(float))];
1260 int t09[T(__is_trivially_copyable(double))];
1261 int t10[T(__is_trivially_copyable(long double))];
1262 int t11[T(__is_trivially_copyable(unsigned char))];
1263 int t12[T(__is_trivially_copyable(unsigned int))];
1264 int t13[T(__is_trivially_copyable(unsigned long long))];
1265 int t14[T(__is_trivially_copyable(unsigned long))];
1266 int t15[T(__is_trivially_copyable(unsigned short))];
1267 int t16[T(__is_trivially_copyable(ClassType))];
1268 int t17[T(__is_trivially_copyable(Derives))];
1269 int t18[T(__is_trivially_copyable(Enum))];
1270 int t19[T(__is_trivially_copyable(IntAr))];
1271 int t20[T(__is_trivially_copyable(Union))];
1272 int t21[T(__is_trivially_copyable(UnionAr))];
1273 int t22[T(__is_trivially_copyable(TrivialStruct))];
1274 int t23[T(__is_trivially_copyable(NonTrivialStruct))];
1275 int t24[T(__is_trivially_copyable(AllDefaulted))];
1276 int t25[T(__is_trivially_copyable(AllDeleted))];
1278 int t30[F(__is_trivially_copyable(void))];
1279 int t31[F(__is_trivially_copyable(SuperNonTrivialStruct))];
1280 int t32[F(__is_trivially_copyable(NonTCStruct))];
1281 int t33[F(__is_trivially_copyable(ExtDefaulted))];
1283 int t34[T(__is_trivially_copyable(const int))];
1284 int t35[T(__is_trivially_copyable(volatile int))];
1286 int t40[T(__is_trivially_copyable(ACompleteType))];
1287 int t41[F(__is_trivially_copyable(AnIncompleteType))]; // expected-error {{incomplete type}}
1288 int t42[F(__is_trivially_copyable(AnIncompleteType[]))]; // expected-error {{incomplete type}}
1289 int t43[F(__is_trivially_copyable(AnIncompleteType[1]))]; // expected-error {{incomplete type}}
1290 int t44[F(__is_trivially_copyable(void))];
1291 int t45[F(__is_trivially_copyable(const volatile void))];
1294 struct CStruct {
1295 int one;
1296 int two;
1299 struct CEmptyStruct {};
1301 struct CppEmptyStruct : CStruct {};
1302 struct CppStructStandard : CEmptyStruct {
1303 int three;
1304 int four;
1306 struct CppStructNonStandardByBase : CStruct {
1307 int three;
1308 int four;
1310 struct CppStructNonStandardByVirt : CStruct {
1311 virtual void method() {}
1313 struct CppStructNonStandardByMemb : CStruct {
1314 CppStructNonStandardByVirt member;
1316 struct CppStructNonStandardByProt : CStruct {
1317 int five;
1318 protected:
1319 int six;
1321 struct CppStructNonStandardByVirtBase : virtual CStruct {
1323 struct CppStructNonStandardBySameBase : CEmptyStruct {
1324 CEmptyStruct member;
1326 struct CppStructNonStandardBy2ndVirtBase : CEmptyStruct {
1327 CEmptyStruct member;
1330 void is_standard_layout()
1332 typedef const int ConstInt;
1333 typedef ConstInt ConstIntAr[4];
1334 typedef CppStructStandard CppStructStandardAr[4];
1336 int t01[T(__is_standard_layout(int))];
1337 int t02[T(__is_standard_layout(ConstInt))];
1338 int t03[T(__is_standard_layout(ConstIntAr))];
1339 int t04[T(__is_standard_layout(CStruct))];
1340 int t05[T(__is_standard_layout(CppStructStandard))];
1341 int t06[T(__is_standard_layout(CppStructStandardAr))];
1342 int t07[T(__is_standard_layout(Vector))];
1343 int t08[T(__is_standard_layout(VectorExt))];
1345 typedef CppStructNonStandardByBase CppStructNonStandardByBaseAr[4];
1347 int t10[F(__is_standard_layout(CppStructNonStandardByVirt))];
1348 int t11[F(__is_standard_layout(CppStructNonStandardByMemb))];
1349 int t12[F(__is_standard_layout(CppStructNonStandardByProt))];
1350 int t13[F(__is_standard_layout(CppStructNonStandardByVirtBase))];
1351 int t14[F(__is_standard_layout(CppStructNonStandardByBase))];
1352 int t15[F(__is_standard_layout(CppStructNonStandardByBaseAr))];
1353 int t16[F(__is_standard_layout(CppStructNonStandardBySameBase))];
1354 int t17[F(__is_standard_layout(CppStructNonStandardBy2ndVirtBase))];
1356 int t40[T(__is_standard_layout(ACompleteType))];
1357 int t41[F(__is_standard_layout(AnIncompleteType))]; // expected-error {{incomplete type}}
1358 int t42[F(__is_standard_layout(AnIncompleteType[]))]; // expected-error {{incomplete type}}
1359 int t43[F(__is_standard_layout(AnIncompleteType[1]))]; // expected-error {{incomplete type}}
1360 int t44[F(__is_standard_layout(void))];
1361 int t45[F(__is_standard_layout(const volatile void))];
1363 struct HasAnonEmptyBitfield { int : 0; };
1364 struct HasAnonBitfield { int : 4; };
1365 struct DerivesFromBitfield : HasAnonBitfield {};
1366 struct DerivesFromBitfieldWithBitfield : HasAnonBitfield { int : 5; };
1367 struct DerivesFromBitfieldTwice : DerivesFromBitfield, HasAnonEmptyBitfield {};
1369 int t50[T(__is_standard_layout(HasAnonEmptyBitfield))];
1370 int t51[T(__is_standard_layout(HasAnonBitfield))];
1371 int t52[T(__is_standard_layout(DerivesFromBitfield))];
1372 int t53[F(__is_standard_layout(DerivesFromBitfieldWithBitfield))];
1373 int t54[F(__is_standard_layout(DerivesFromBitfieldTwice))];
1375 struct Empty {};
1376 struct HasEmptyBase : Empty {};
1377 struct HoldsEmptyBase { Empty e; };
1378 struct HasRepeatedEmptyBase : Empty, HasEmptyBase {}; // expected-warning {{inaccessible}}
1379 struct HasEmptyBaseAsMember : Empty { Empty e; };
1380 struct HasEmptyBaseAsSubobjectOfMember1 : Empty { HoldsEmptyBase e; };
1381 struct HasEmptyBaseAsSubobjectOfMember2 : Empty { HasEmptyBase e; };
1382 struct HasEmptyBaseAsSubobjectOfMember3 : Empty { HoldsEmptyBase e[2]; };
1383 struct HasEmptyIndirectBaseAsMember : HasEmptyBase { Empty e; };
1384 struct HasEmptyIndirectBaseAsSecondMember : HasEmptyBase { int n; Empty e; };
1385 struct HasEmptyIndirectBaseAfterBitfield : HasEmptyBase { int : 4; Empty e; };
1387 int t60[T(__is_standard_layout(Empty))];
1388 int t61[T(__is_standard_layout(HasEmptyBase))];
1389 int t62[F(__is_standard_layout(HasRepeatedEmptyBase))];
1390 int t63[F(__is_standard_layout(HasEmptyBaseAsMember))];
1391 int t64[F(__is_standard_layout(HasEmptyBaseAsSubobjectOfMember1))];
1392 int t65[T(__is_standard_layout(HasEmptyBaseAsSubobjectOfMember2))]; // FIXME: standard bug?
1393 int t66[F(__is_standard_layout(HasEmptyBaseAsSubobjectOfMember3))];
1394 int t67[F(__is_standard_layout(HasEmptyIndirectBaseAsMember))];
1395 int t68[T(__is_standard_layout(HasEmptyIndirectBaseAsSecondMember))];
1396 int t69[F(__is_standard_layout(HasEmptyIndirectBaseAfterBitfield))]; // FIXME: standard bug?
1398 struct StructWithEmptyFields {
1399 int n;
1400 HoldsEmptyBase e[3];
1402 union UnionWithEmptyFields {
1403 int n;
1404 HoldsEmptyBase e[3];
1406 struct HasEmptyIndirectBaseAsSecondStructMember : HasEmptyBase {
1407 StructWithEmptyFields u;
1409 struct HasEmptyIndirectBaseAsSecondUnionMember : HasEmptyBase {
1410 UnionWithEmptyFields u;
1413 int t70[T(__is_standard_layout(HasEmptyIndirectBaseAsSecondStructMember))];
1414 int t71[F(__is_standard_layout(HasEmptyIndirectBaseAsSecondUnionMember))];
1417 void is_signed()
1419 //int t01[T(__is_signed(char))];
1420 int t02[T(__is_signed(int))];
1421 int t03[T(__is_signed(long))];
1422 int t04[T(__is_signed(short))];
1423 int t05[T(__is_signed(signed char))];
1424 int t06[T(__is_signed(wchar_t))];
1425 int t07[T(__is_signed(float))];
1426 int t08[T(__is_signed(double))];
1427 int t09[T(__is_signed(long double))];
1429 int t13[F(__is_signed(bool))];
1430 int t14[F(__is_signed(cvoid))];
1431 int t15[F(__is_signed(unsigned char))];
1432 int t16[F(__is_signed(unsigned int))];
1433 int t17[F(__is_signed(unsigned long long))];
1434 int t18[F(__is_signed(unsigned long))];
1435 int t19[F(__is_signed(unsigned short))];
1436 int t20[F(__is_signed(void))];
1437 int t21[F(__is_signed(ClassType))];
1438 int t22[F(__is_signed(Derives))];
1439 int t23[F(__is_signed(Enum))];
1440 int t24[F(__is_signed(SignedEnum))];
1441 int t25[F(__is_signed(IntArNB))];
1442 int t26[F(__is_signed(Union))];
1443 int t27[F(__is_signed(UnionAr))];
1444 int t28[F(__is_signed(UnsignedEnum))];
1447 void is_unsigned()
1449 int t01[T(__is_unsigned(bool))];
1450 int t02[T(__is_unsigned(unsigned char))];
1451 int t03[T(__is_unsigned(unsigned short))];
1452 int t04[T(__is_unsigned(unsigned int))];
1453 int t05[T(__is_unsigned(unsigned long))];
1454 int t06[T(__is_unsigned(unsigned long long))];
1456 int t10[F(__is_unsigned(void))];
1457 int t11[F(__is_unsigned(cvoid))];
1458 int t12[F(__is_unsigned(float))];
1459 int t13[F(__is_unsigned(double))];
1460 int t14[F(__is_unsigned(long double))];
1461 int t16[F(__is_unsigned(char))];
1462 int t17[F(__is_unsigned(signed char))];
1463 int t18[F(__is_unsigned(wchar_t))];
1464 int t19[F(__is_unsigned(short))];
1465 int t20[F(__is_unsigned(int))];
1466 int t21[F(__is_unsigned(long))];
1467 int t22[F(__is_unsigned(Union))];
1468 int t23[F(__is_unsigned(UnionAr))];
1469 int t24[F(__is_unsigned(Derives))];
1470 int t25[F(__is_unsigned(ClassType))];
1471 int t26[F(__is_unsigned(IntArNB))];
1472 int t27[F(__is_unsigned(Enum))];
1473 int t28[F(__is_unsigned(UnsignedEnum))];
1474 int t29[F(__is_unsigned(SignedEnum))];
1477 typedef Int& IntRef;
1478 typedef const IntAr ConstIntAr;
1479 typedef ConstIntAr ConstIntArAr[4];
1481 struct HasCopy {
1482 HasCopy(HasCopy& cp);
1485 struct HasMove {
1486 HasMove(HasMove&& cp);
1489 struct HasTemplateCons {
1490 HasVirt Annoying;
1492 template <typename T>
1493 HasTemplateCons(const T&);
1496 void has_trivial_default_constructor() {
1497 { int arr[T(__has_trivial_constructor(Int))]; }
1498 { int arr[T(__has_trivial_constructor(IntAr))]; }
1499 { int arr[T(__has_trivial_constructor(Union))]; }
1500 { int arr[T(__has_trivial_constructor(UnionAr))]; }
1501 { int arr[T(__has_trivial_constructor(POD))]; }
1502 { int arr[T(__has_trivial_constructor(Derives))]; }
1503 { int arr[T(__has_trivial_constructor(DerivesAr))]; }
1504 { int arr[T(__has_trivial_constructor(ConstIntAr))]; }
1505 { int arr[T(__has_trivial_constructor(ConstIntArAr))]; }
1506 { int arr[T(__has_trivial_constructor(HasDest))]; }
1507 { int arr[T(__has_trivial_constructor(HasPriv))]; }
1508 { int arr[T(__has_trivial_constructor(HasCopyAssign))]; }
1509 { int arr[T(__has_trivial_constructor(HasMoveAssign))]; }
1510 { int arr[T(__has_trivial_constructor(const Int))]; }
1511 { int arr[T(__has_trivial_constructor(AllDefaulted))]; }
1512 { int arr[T(__has_trivial_constructor(AllDeleted))]; }
1513 { int arr[T(__has_trivial_constructor(ACompleteType[]))]; }
1515 { int arr[F(__has_trivial_constructor(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1516 { int arr[F(__has_trivial_constructor(HasCons))]; }
1517 { int arr[F(__has_trivial_constructor(HasRef))]; }
1518 { int arr[F(__has_trivial_constructor(HasCopy))]; }
1519 { int arr[F(__has_trivial_constructor(IntRef))]; }
1520 { int arr[F(__has_trivial_constructor(VirtAr))]; }
1521 { int arr[F(__has_trivial_constructor(void))]; }
1522 { int arr[F(__has_trivial_constructor(cvoid))]; }
1523 { int arr[F(__has_trivial_constructor(HasTemplateCons))]; }
1524 { int arr[F(__has_trivial_constructor(AllPrivate))]; }
1525 { int arr[F(__has_trivial_constructor(ExtDefaulted))]; }
1528 void has_trivial_move_constructor() {
1529 // n3376 12.8 [class.copy]/12
1530 // A copy/move constructor for class X is trivial if it is not
1531 // user-provided, its declared parameter type is the same as
1532 // if it had been implicitly declared, and if
1533 // - class X has no virtual functions (10.3) and no virtual
1534 // base classes (10.1), and
1535 // - the constructor selected to copy/move each direct base
1536 // class subobject is trivial, and
1537 // - for each non-static data member of X that is of class
1538 // type (or array thereof), the constructor selected
1539 // to copy/move that member is trivial;
1540 // otherwise the copy/move constructor is non-trivial.
1541 { int arr[T(__has_trivial_move_constructor(POD))]; }
1542 { int arr[T(__has_trivial_move_constructor(Union))]; }
1543 { int arr[T(__has_trivial_move_constructor(HasCons))]; }
1544 { int arr[T(__has_trivial_move_constructor(HasStaticMemberMoveCtor))]; }
1545 { int arr[T(__has_trivial_move_constructor(AllDeleted))]; }
1546 { int arr[T(__has_trivial_move_constructor(ACompleteType[]))]; }
1548 { int arr[F(__has_trivial_move_constructor(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1549 { int arr[F(__has_trivial_move_constructor(HasVirt))]; }
1550 { int arr[F(__has_trivial_move_constructor(DerivesVirt))]; }
1551 { int arr[F(__has_trivial_move_constructor(HasMoveCtor))]; }
1552 { int arr[F(__has_trivial_move_constructor(DerivesHasMoveCtor))]; }
1553 { int arr[F(__has_trivial_move_constructor(HasMemberMoveCtor))]; }
1556 void has_trivial_copy_constructor() {
1557 { int arr[T(__has_trivial_copy(Int))]; }
1558 { int arr[T(__has_trivial_copy(IntAr))]; }
1559 { int arr[T(__has_trivial_copy(Union))]; }
1560 { int arr[T(__has_trivial_copy(UnionAr))]; }
1561 { int arr[T(__has_trivial_copy(POD))]; }
1562 { int arr[T(__has_trivial_copy(Derives))]; }
1563 { int arr[T(__has_trivial_copy(ConstIntAr))]; }
1564 { int arr[T(__has_trivial_copy(ConstIntArAr))]; }
1565 { int arr[T(__has_trivial_copy(HasDest))]; }
1566 { int arr[T(__has_trivial_copy(HasPriv))]; }
1567 { int arr[T(__has_trivial_copy(HasCons))]; }
1568 { int arr[T(__has_trivial_copy(HasRef))]; }
1569 { int arr[T(__has_trivial_copy(HasMove))]; }
1570 { int arr[T(__has_trivial_copy(IntRef))]; }
1571 { int arr[T(__has_trivial_copy(HasCopyAssign))]; }
1572 { int arr[T(__has_trivial_copy(HasMoveAssign))]; }
1573 { int arr[T(__has_trivial_copy(const Int))]; }
1574 { int arr[T(__has_trivial_copy(AllDefaulted))]; }
1575 { int arr[T(__has_trivial_copy(AllDeleted))]; }
1576 { int arr[T(__has_trivial_copy(DerivesAr))]; }
1577 { int arr[T(__has_trivial_copy(DerivesHasRef))]; }
1578 { int arr[T(__has_trivial_copy(ACompleteType[]))]; }
1580 { int arr[F(__has_trivial_copy(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1581 { int arr[F(__has_trivial_copy(HasCopy))]; }
1582 { int arr[F(__has_trivial_copy(HasTemplateCons))]; }
1583 { int arr[F(__has_trivial_copy(VirtAr))]; }
1584 { int arr[F(__has_trivial_copy(void))]; }
1585 { int arr[F(__has_trivial_copy(cvoid))]; }
1586 { int arr[F(__has_trivial_copy(AllPrivate))]; }
1587 { int arr[F(__has_trivial_copy(ExtDefaulted))]; }
1590 void has_trivial_copy_assignment() {
1591 { int arr[T(__has_trivial_assign(Int))]; }
1592 { int arr[T(__has_trivial_assign(IntAr))]; }
1593 { int arr[T(__has_trivial_assign(Union))]; }
1594 { int arr[T(__has_trivial_assign(UnionAr))]; }
1595 { int arr[T(__has_trivial_assign(POD))]; }
1596 { int arr[T(__has_trivial_assign(Derives))]; }
1597 { int arr[T(__has_trivial_assign(HasDest))]; }
1598 { int arr[T(__has_trivial_assign(HasPriv))]; }
1599 { int arr[T(__has_trivial_assign(HasCons))]; }
1600 { int arr[T(__has_trivial_assign(HasRef))]; }
1601 { int arr[T(__has_trivial_assign(HasCopy))]; }
1602 { int arr[T(__has_trivial_assign(HasMove))]; }
1603 { int arr[T(__has_trivial_assign(HasMoveAssign))]; }
1604 { int arr[T(__has_trivial_assign(AllDefaulted))]; }
1605 { int arr[T(__has_trivial_assign(AllDeleted))]; }
1606 { int arr[T(__has_trivial_assign(DerivesAr))]; }
1607 { int arr[T(__has_trivial_assign(DerivesHasRef))]; }
1608 { int arr[T(__has_trivial_assign(ACompleteType[]))]; }
1610 { int arr[F(__has_trivial_assign(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1611 { int arr[F(__has_trivial_assign(IntRef))]; }
1612 { int arr[F(__has_trivial_assign(HasCopyAssign))]; }
1613 { int arr[F(__has_trivial_assign(const Int))]; }
1614 { int arr[F(__has_trivial_assign(ConstIntAr))]; }
1615 { int arr[F(__has_trivial_assign(ConstIntArAr))]; }
1616 { int arr[F(__has_trivial_assign(VirtAr))]; }
1617 { int arr[F(__has_trivial_assign(void))]; }
1618 { int arr[F(__has_trivial_assign(cvoid))]; }
1619 { int arr[F(__has_trivial_assign(AllPrivate))]; }
1620 { int arr[F(__has_trivial_assign(ExtDefaulted))]; }
1623 void has_trivial_destructor() {
1624 { int arr[T(__has_trivial_destructor(Int))]; }
1625 { int arr[T(__has_trivial_destructor(IntAr))]; }
1626 { int arr[T(__has_trivial_destructor(Union))]; }
1627 { int arr[T(__has_trivial_destructor(UnionAr))]; }
1628 { int arr[T(__has_trivial_destructor(POD))]; }
1629 { int arr[T(__has_trivial_destructor(Derives))]; }
1630 { int arr[T(__has_trivial_destructor(ConstIntAr))]; }
1631 { int arr[T(__has_trivial_destructor(ConstIntArAr))]; }
1632 { int arr[T(__has_trivial_destructor(HasPriv))]; }
1633 { int arr[T(__has_trivial_destructor(HasCons))]; }
1634 { int arr[T(__has_trivial_destructor(HasRef))]; }
1635 { int arr[T(__has_trivial_destructor(HasCopy))]; }
1636 { int arr[T(__has_trivial_destructor(HasMove))]; }
1637 { int arr[T(__has_trivial_destructor(IntRef))]; }
1638 { int arr[T(__has_trivial_destructor(HasCopyAssign))]; }
1639 { int arr[T(__has_trivial_destructor(HasMoveAssign))]; }
1640 { int arr[T(__has_trivial_destructor(const Int))]; }
1641 { int arr[T(__has_trivial_destructor(DerivesAr))]; }
1642 { int arr[T(__has_trivial_destructor(VirtAr))]; }
1643 { int arr[T(__has_trivial_destructor(AllDefaulted))]; }
1644 { int arr[T(__has_trivial_destructor(AllDeleted))]; }
1645 { int arr[T(__has_trivial_destructor(DerivesHasRef))]; }
1646 { int arr[T(__has_trivial_destructor(ACompleteType[]))]; }
1648 { int arr[F(__has_trivial_destructor(HasDest))]; }
1649 { int arr[F(__has_trivial_destructor(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1650 { int arr[F(__has_trivial_destructor(void))]; }
1651 { int arr[F(__has_trivial_destructor(cvoid))]; }
1652 { int arr[F(__has_trivial_destructor(AllPrivate))]; }
1653 { int arr[F(__has_trivial_destructor(ExtDefaulted))]; }
1656 struct A { ~A() {} };
1657 template<typename> struct B : A { };
1659 void f() {
1660 { int arr[F(__has_trivial_destructor(A))]; }
1661 { int arr[F(__has_trivial_destructor(B<int>))]; }
1664 class PR11110 {
1665 template <int> int operator=( int );
1666 int operator=(PR11110);
1669 class UsingAssign;
1671 class UsingAssignBase {
1672 protected:
1673 UsingAssign &operator=(const UsingAssign&) throw();
1676 class UsingAssign : public UsingAssignBase {
1677 public:
1678 using UsingAssignBase::operator=;
1681 void has_nothrow_assign() {
1682 { int arr[T(__has_nothrow_assign(Int))]; }
1683 { int arr[T(__has_nothrow_assign(IntAr))]; }
1684 { int arr[T(__has_nothrow_assign(Union))]; }
1685 { int arr[T(__has_nothrow_assign(UnionAr))]; }
1686 { int arr[T(__has_nothrow_assign(POD))]; }
1687 { int arr[T(__has_nothrow_assign(Derives))]; }
1688 { int arr[T(__has_nothrow_assign(HasDest))]; }
1689 { int arr[T(__has_nothrow_assign(HasPriv))]; }
1690 { int arr[T(__has_nothrow_assign(HasCons))]; }
1691 { int arr[T(__has_nothrow_assign(HasRef))]; }
1692 { int arr[T(__has_nothrow_assign(HasCopy))]; }
1693 { int arr[T(__has_nothrow_assign(HasMove))]; }
1694 { int arr[T(__has_nothrow_assign(HasMoveAssign))]; }
1695 { int arr[T(__has_nothrow_assign(HasNoThrowCopyAssign))]; }
1696 { int arr[T(__has_nothrow_assign(HasMultipleNoThrowCopyAssign))]; }
1697 { int arr[T(__has_nothrow_assign(HasVirtDest))]; }
1698 { int arr[T(__has_nothrow_assign(AllPrivate))]; }
1699 { int arr[T(__has_nothrow_assign(UsingAssign))]; }
1700 { int arr[T(__has_nothrow_assign(DerivesAr))]; }
1701 { int arr[T(__has_nothrow_assign(ACompleteType[]))]; }
1703 { int arr[F(__has_nothrow_assign(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1704 { int arr[F(__has_nothrow_assign(IntRef))]; }
1705 { int arr[F(__has_nothrow_assign(HasCopyAssign))]; }
1706 { int arr[F(__has_nothrow_assign(HasMultipleCopyAssign))]; }
1707 { int arr[F(__has_nothrow_assign(const Int))]; }
1708 { int arr[F(__has_nothrow_assign(ConstIntAr))]; }
1709 { int arr[F(__has_nothrow_assign(ConstIntArAr))]; }
1710 { int arr[F(__has_nothrow_assign(VirtAr))]; }
1711 { int arr[F(__has_nothrow_assign(void))]; }
1712 { int arr[F(__has_nothrow_assign(cvoid))]; }
1713 { int arr[F(__has_nothrow_assign(PR11110))]; }
1716 void has_nothrow_move_assign() {
1717 { int arr[T(__has_nothrow_move_assign(Int))]; }
1718 { int arr[T(__has_nothrow_move_assign(Enum))]; }
1719 { int arr[T(__has_nothrow_move_assign(Int*))]; }
1720 { int arr[T(__has_nothrow_move_assign(Enum POD::*))]; }
1721 { int arr[T(__has_nothrow_move_assign(POD))]; }
1722 { int arr[T(__has_nothrow_move_assign(HasPriv))]; }
1723 { int arr[T(__has_nothrow_move_assign(HasNoThrowMoveAssign))]; }
1724 { int arr[T(__has_nothrow_move_assign(HasNoExceptNoThrowMoveAssign))]; }
1725 { int arr[T(__has_nothrow_move_assign(HasMemberNoThrowMoveAssign))]; }
1726 { int arr[T(__has_nothrow_move_assign(HasMemberNoExceptNoThrowMoveAssign))]; }
1727 { int arr[T(__has_nothrow_move_assign(AllDeleted))]; }
1728 { int arr[T(__has_nothrow_move_assign(ACompleteType[]))]; }
1730 { int arr[F(__has_nothrow_move_assign(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1731 { int arr[F(__has_nothrow_move_assign(HasThrowMoveAssign))]; }
1732 { int arr[F(__has_nothrow_move_assign(HasNoExceptFalseMoveAssign))]; }
1733 { int arr[F(__has_nothrow_move_assign(HasMemberThrowMoveAssign))]; }
1734 { int arr[F(__has_nothrow_move_assign(HasMemberNoExceptFalseMoveAssign))]; }
1735 { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyCtor))]; }
1736 { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyAssign))]; }
1737 { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToDtor))]; }
1740 { int arr[T(__is_nothrow_assignable(HasNoThrowMoveAssign, HasNoThrowMoveAssign))]; }
1741 { int arr[F(__is_nothrow_assignable(HasThrowMoveAssign, HasThrowMoveAssign))]; }
1743 { int arr[T(__is_assignable(HasNoThrowMoveAssign, HasNoThrowMoveAssign))]; }
1744 { int arr[T(__is_assignable(HasThrowMoveAssign, HasThrowMoveAssign))]; }
1747 void has_trivial_move_assign() {
1748 // n3376 12.8 [class.copy]/25
1749 // A copy/move assignment operator for class X is trivial if it
1750 // is not user-provided, its declared parameter type is the same
1751 // as if it had been implicitly declared, and if:
1752 // - class X has no virtual functions (10.3) and no virtual base
1753 // classes (10.1), and
1754 // - the assignment operator selected to copy/move each direct
1755 // base class subobject is trivial, and
1756 // - for each non-static data member of X that is of class type
1757 // (or array thereof), the assignment operator
1758 // selected to copy/move that member is trivial;
1759 { int arr[T(__has_trivial_move_assign(Int))]; }
1760 { int arr[T(__has_trivial_move_assign(HasStaticMemberMoveAssign))]; }
1761 { int arr[T(__has_trivial_move_assign(AllDeleted))]; }
1762 { int arr[T(__has_trivial_move_assign(ACompleteType[]))]; }
1764 { int arr[F(__has_trivial_move_assign(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1765 { int arr[F(__has_trivial_move_assign(HasVirt))]; }
1766 { int arr[F(__has_trivial_move_assign(DerivesVirt))]; }
1767 { int arr[F(__has_trivial_move_assign(HasMoveAssign))]; }
1768 { int arr[F(__has_trivial_move_assign(DerivesHasMoveAssign))]; }
1769 { int arr[F(__has_trivial_move_assign(HasMemberMoveAssign))]; }
1770 { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyCtor))]; }
1771 { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyAssign))]; }
1774 void has_nothrow_copy() {
1775 { int arr[T(__has_nothrow_copy(Int))]; }
1776 { int arr[T(__has_nothrow_copy(IntAr))]; }
1777 { int arr[T(__has_nothrow_copy(Union))]; }
1778 { int arr[T(__has_nothrow_copy(UnionAr))]; }
1779 { int arr[T(__has_nothrow_copy(POD))]; }
1780 { int arr[T(__has_nothrow_copy(const Int))]; }
1781 { int arr[T(__has_nothrow_copy(ConstIntAr))]; }
1782 { int arr[T(__has_nothrow_copy(ConstIntArAr))]; }
1783 { int arr[T(__has_nothrow_copy(Derives))]; }
1784 { int arr[T(__has_nothrow_copy(IntRef))]; }
1785 { int arr[T(__has_nothrow_copy(HasDest))]; }
1786 { int arr[T(__has_nothrow_copy(HasPriv))]; }
1787 { int arr[T(__has_nothrow_copy(HasCons))]; }
1788 { int arr[T(__has_nothrow_copy(HasRef))]; }
1789 { int arr[T(__has_nothrow_copy(HasMove))]; }
1790 { int arr[T(__has_nothrow_copy(HasCopyAssign))]; }
1791 { int arr[T(__has_nothrow_copy(HasMoveAssign))]; }
1792 { int arr[T(__has_nothrow_copy(HasNoThrowCopy))]; }
1793 { int arr[T(__has_nothrow_copy(HasMultipleNoThrowCopy))]; }
1794 { int arr[T(__has_nothrow_copy(HasVirtDest))]; }
1795 { int arr[T(__has_nothrow_copy(HasTemplateCons))]; }
1796 { int arr[T(__has_nothrow_copy(AllPrivate))]; }
1797 { int arr[T(__has_nothrow_copy(DerivesAr))]; }
1798 { int arr[T(__has_nothrow_copy(ACompleteType[]))]; }
1800 { int arr[F(__has_nothrow_copy(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1801 { int arr[F(__has_nothrow_copy(HasCopy))]; }
1802 { int arr[F(__has_nothrow_copy(HasMultipleCopy))]; }
1803 { int arr[F(__has_nothrow_copy(VirtAr))]; }
1804 { int arr[F(__has_nothrow_copy(void))]; }
1805 { int arr[F(__has_nothrow_copy(cvoid))]; }
1808 void has_nothrow_constructor() {
1809 { int arr[T(__has_nothrow_constructor(Int))]; }
1810 { int arr[T(__has_nothrow_constructor(IntAr))]; }
1811 { int arr[T(__has_nothrow_constructor(Union))]; }
1812 { int arr[T(__has_nothrow_constructor(UnionAr))]; }
1813 { int arr[T(__has_nothrow_constructor(POD))]; }
1814 { int arr[T(__has_nothrow_constructor(Derives))]; }
1815 { int arr[T(__has_nothrow_constructor(DerivesAr))]; }
1816 { int arr[T(__has_nothrow_constructor(ConstIntAr))]; }
1817 { int arr[T(__has_nothrow_constructor(ConstIntArAr))]; }
1818 { int arr[T(__has_nothrow_constructor(HasDest))]; }
1819 { int arr[T(__has_nothrow_constructor(HasPriv))]; }
1820 { int arr[T(__has_nothrow_constructor(HasCopyAssign))]; }
1821 { int arr[T(__has_nothrow_constructor(const Int))]; }
1822 { int arr[T(__has_nothrow_constructor(HasNoThrowConstructor))]; }
1823 { int arr[T(__has_nothrow_constructor(HasVirtDest))]; }
1824 // { int arr[T(__has_nothrow_constructor(VirtAr))]; } // not implemented
1825 { int arr[T(__has_nothrow_constructor(AllPrivate))]; }
1826 { int arr[T(__has_nothrow_constructor(ACompleteType[]))]; }
1828 { int arr[F(__has_nothrow_constructor(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1829 { int arr[F(__has_nothrow_constructor(HasCons))]; }
1830 { int arr[F(__has_nothrow_constructor(HasRef))]; }
1831 { int arr[F(__has_nothrow_constructor(HasCopy))]; }
1832 { int arr[F(__has_nothrow_constructor(HasMove))]; }
1833 { int arr[F(__has_nothrow_constructor(HasNoThrowConstructorWithArgs))]; }
1834 { int arr[F(__has_nothrow_constructor(IntRef))]; }
1835 { int arr[F(__has_nothrow_constructor(void))]; }
1836 { int arr[F(__has_nothrow_constructor(cvoid))]; }
1837 { int arr[F(__has_nothrow_constructor(HasTemplateCons))]; }
1839 { int arr[F(__has_nothrow_constructor(HasMultipleDefaultConstructor1))]; }
1840 { int arr[F(__has_nothrow_constructor(HasMultipleDefaultConstructor2))]; }
1843 void has_virtual_destructor() {
1844 { int arr[F(__has_virtual_destructor(Int))]; }
1845 { int arr[F(__has_virtual_destructor(IntAr))]; }
1846 { int arr[F(__has_virtual_destructor(Union))]; }
1847 { int arr[F(__has_virtual_destructor(UnionAr))]; }
1848 { int arr[F(__has_virtual_destructor(POD))]; }
1849 { int arr[F(__has_virtual_destructor(Derives))]; }
1850 { int arr[F(__has_virtual_destructor(DerivesAr))]; }
1851 { int arr[F(__has_virtual_destructor(const Int))]; }
1852 { int arr[F(__has_virtual_destructor(ConstIntAr))]; }
1853 { int arr[F(__has_virtual_destructor(ConstIntArAr))]; }
1854 { int arr[F(__has_virtual_destructor(HasDest))]; }
1855 { int arr[F(__has_virtual_destructor(HasPriv))]; }
1856 { int arr[F(__has_virtual_destructor(HasCons))]; }
1857 { int arr[F(__has_virtual_destructor(HasRef))]; }
1858 { int arr[F(__has_virtual_destructor(HasCopy))]; }
1859 { int arr[F(__has_virtual_destructor(HasMove))]; }
1860 { int arr[F(__has_virtual_destructor(HasCopyAssign))]; }
1861 { int arr[F(__has_virtual_destructor(HasMoveAssign))]; }
1862 { int arr[F(__has_virtual_destructor(IntRef))]; }
1863 { int arr[F(__has_virtual_destructor(VirtAr))]; }
1864 { int arr[F(__has_virtual_destructor(ACompleteType[]))]; }
1866 { int arr[F(__has_virtual_destructor(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1867 { int arr[T(__has_virtual_destructor(HasVirtDest))]; }
1868 { int arr[T(__has_virtual_destructor(DerivedVirtDest))]; }
1869 { int arr[F(__has_virtual_destructor(VirtDestAr))]; }
1870 { int arr[F(__has_virtual_destructor(void))]; }
1871 { int arr[F(__has_virtual_destructor(cvoid))]; }
1872 { int arr[F(__has_virtual_destructor(AllPrivate))]; }
1876 class Base {};
1877 class Derived : Base {};
1878 class Derived2a : Derived {};
1879 class Derived2b : Derived {};
1880 class Derived3 : virtual Derived2a, virtual Derived2b {};
1881 template<typename T> struct BaseA { T a; };
1882 template<typename T> struct DerivedB : BaseA<T> { };
1883 template<typename T> struct CrazyDerived : T { };
1886 class class_forward; // expected-note 2 {{forward declaration of 'class_forward'}}
1888 template <typename Base, typename Derived>
1889 void isBaseOfT() {
1890 int t[T(__is_base_of(Base, Derived))];
1892 template <typename Base, typename Derived>
1893 void isBaseOfF() {
1894 int t[F(__is_base_of(Base, Derived))];
1897 template <class T> class DerivedTemp : Base {};
1898 template <class T> class NonderivedTemp {};
1899 template <class T> class UndefinedTemp; // expected-note {{declared here}}
1901 void is_base_of() {
1902 { int arr[T(__is_base_of(Base, Derived))]; }
1903 { int arr[T(__is_base_of(const Base, Derived))]; }
1904 { int arr[F(__is_base_of(Derived, Base))]; }
1905 { int arr[F(__is_base_of(Derived, int))]; }
1906 { int arr[T(__is_base_of(Base, Base))]; }
1907 { int arr[T(__is_base_of(Base, Derived3))]; }
1908 { int arr[T(__is_base_of(Derived, Derived3))]; }
1909 { int arr[T(__is_base_of(Derived2b, Derived3))]; }
1910 { int arr[T(__is_base_of(Derived2a, Derived3))]; }
1911 { int arr[T(__is_base_of(BaseA<int>, DerivedB<int>))]; }
1912 { int arr[F(__is_base_of(DerivedB<int>, BaseA<int>))]; }
1913 { int arr[T(__is_base_of(Base, CrazyDerived<Base>))]; }
1914 { int arr[F(__is_base_of(Union, Union))]; }
1915 { int arr[T(__is_base_of(Empty, Empty))]; }
1916 { int arr[T(__is_base_of(class_forward, class_forward))]; }
1917 { int arr[F(__is_base_of(Empty, class_forward))]; } // expected-error {{incomplete type 'class_forward' used in type trait expression}}
1918 { int arr[F(__is_base_of(Base&, Derived&))]; }
1919 int t18[F(__is_base_of(Base[10], Derived[10]))];
1920 { int arr[F(__is_base_of(int, int))]; }
1921 { int arr[F(__is_base_of(long, int))]; }
1922 { int arr[T(__is_base_of(Base, DerivedTemp<int>))]; }
1923 { int arr[F(__is_base_of(Base, NonderivedTemp<int>))]; }
1924 { int arr[F(__is_base_of(Base, UndefinedTemp<int>))]; } // expected-error {{implicit instantiation of undefined template 'UndefinedTemp<int>'}}
1926 { int arr[F(__is_base_of(IncompleteUnion, IncompleteUnion))]; }
1927 { int arr[F(__is_base_of(Union, IncompleteUnion))]; }
1928 { int arr[F(__is_base_of(IncompleteUnion, Union))]; }
1929 { int arr[F(__is_base_of(IncompleteStruct, IncompleteUnion))]; }
1930 { int arr[F(__is_base_of(IncompleteUnion, IncompleteStruct))]; }
1931 { int arr[F(__is_base_of(Empty, IncompleteUnion))]; }
1932 { int arr[F(__is_base_of(IncompleteUnion, Empty))]; }
1933 { int arr[F(__is_base_of(int, IncompleteUnion))]; }
1934 { int arr[F(__is_base_of(IncompleteUnion, int))]; }
1935 { int arr[F(__is_base_of(Empty, Union))]; }
1936 { int arr[F(__is_base_of(Union, Empty))]; }
1937 { int arr[F(__is_base_of(int, Empty))]; }
1938 { int arr[F(__is_base_of(Union, int))]; }
1940 isBaseOfT<Base, Derived>();
1941 isBaseOfF<Derived, Base>();
1943 isBaseOfT<Base, CrazyDerived<Base> >();
1944 isBaseOfF<CrazyDerived<Base>, Base>();
1946 isBaseOfT<BaseA<int>, DerivedB<int> >();
1947 isBaseOfF<DerivedB<int>, BaseA<int> >();
1950 template<class T, class U>
1951 class TemplateClass {};
1953 template<class T>
1954 using TemplateAlias = TemplateClass<T, int>;
1956 typedef class Base BaseTypedef;
1958 void is_same()
1960 int t01[T(__is_same(Base, Base))];
1961 int t02[T(__is_same(Base, BaseTypedef))];
1962 int t03[T(__is_same(TemplateClass<int, int>, TemplateAlias<int>))];
1964 int t10[F(__is_same(Base, const Base))];
1965 int t11[F(__is_same(Base, Base&))];
1966 int t12[F(__is_same(Base, Derived))];
1968 // __is_same_as is a GCC compatibility synonym for __is_same.
1969 int t20[T(__is_same_as(int, int))];
1970 int t21[F(__is_same_as(int, float))];
1973 struct IntWrapper
1975 int value;
1976 IntWrapper(int _value) : value(_value) {}
1977 operator int() const {
1978 return value;
1982 struct FloatWrapper
1984 float value;
1985 FloatWrapper(float _value) : value(_value) {}
1986 FloatWrapper(const IntWrapper& obj)
1987 : value(static_cast<float>(obj.value)) {}
1988 operator float() const {
1989 return value;
1991 operator IntWrapper() const {
1992 return IntWrapper(static_cast<int>(value));
1996 void is_convertible()
1998 int t01[T(__is_convertible(IntWrapper, IntWrapper))];
1999 int t02[T(__is_convertible(IntWrapper, const IntWrapper))];
2000 int t03[T(__is_convertible(IntWrapper, int))];
2001 int t04[T(__is_convertible(int, IntWrapper))];
2002 int t05[T(__is_convertible(IntWrapper, FloatWrapper))];
2003 int t06[T(__is_convertible(FloatWrapper, IntWrapper))];
2004 int t07[T(__is_convertible(FloatWrapper, float))];
2005 int t08[T(__is_convertible(float, FloatWrapper))];
2008 struct FromInt { FromInt(int); };
2009 struct ToInt { operator int(); };
2010 typedef void Function();
2012 void is_convertible_to();
2013 class PrivateCopy {
2014 PrivateCopy(const PrivateCopy&);
2015 friend void is_convertible_to();
2018 template<typename T>
2019 struct X0 {
2020 template<typename U> X0(const X0<U>&);
2023 struct Abstract { virtual void f() = 0; };
2025 void is_convertible_to() {
2026 { int arr[T(__is_convertible_to(Int, Int))]; }
2027 { int arr[F(__is_convertible_to(Int, IntAr))]; }
2028 { int arr[F(__is_convertible_to(IntAr, IntAr))]; }
2029 { int arr[T(__is_convertible_to(void, void))]; }
2030 { int arr[T(__is_convertible_to(cvoid, void))]; }
2031 { int arr[T(__is_convertible_to(void, cvoid))]; }
2032 { int arr[T(__is_convertible_to(cvoid, cvoid))]; }
2033 { int arr[T(__is_convertible_to(int, FromInt))]; }
2034 { int arr[T(__is_convertible_to(long, FromInt))]; }
2035 { int arr[T(__is_convertible_to(double, FromInt))]; }
2036 { int arr[T(__is_convertible_to(const int, FromInt))]; }
2037 { int arr[T(__is_convertible_to(const int&, FromInt))]; }
2038 { int arr[T(__is_convertible_to(ToInt, int))]; }
2039 { int arr[T(__is_convertible_to(ToInt, const int&))]; }
2040 { int arr[T(__is_convertible_to(ToInt, long))]; }
2041 { int arr[F(__is_convertible_to(ToInt, int&))]; }
2042 { int arr[F(__is_convertible_to(ToInt, FromInt))]; }
2043 { int arr[T(__is_convertible_to(IntAr&, IntAr&))]; }
2044 { int arr[T(__is_convertible_to(IntAr&, const IntAr&))]; }
2045 { int arr[F(__is_convertible_to(const IntAr&, IntAr&))]; }
2046 { int arr[F(__is_convertible_to(Function, Function))]; }
2047 { int arr[F(__is_convertible_to(PrivateCopy, PrivateCopy))]; }
2048 { int arr[T(__is_convertible_to(X0<int>, X0<float>))]; }
2049 { int arr[F(__is_convertible_to(Abstract, Abstract))]; }
2052 namespace is_convertible_to_instantiate {
2053 // Make sure we don't try to instantiate the constructor.
2054 template<int x> class A { A(int) { int a[x]; } };
2055 int x = __is_convertible_to(int, A<-1>);
2058 void is_trivial()
2060 { int arr[T(__is_trivial(int))]; }
2061 { int arr[T(__is_trivial(Enum))]; }
2062 { int arr[T(__is_trivial(POD))]; }
2063 { int arr[T(__is_trivial(Int))]; }
2064 { int arr[T(__is_trivial(IntAr))]; }
2065 { int arr[T(__is_trivial(IntArNB))]; }
2066 { int arr[T(__is_trivial(Statics))]; }
2067 { int arr[T(__is_trivial(Empty))]; }
2068 { int arr[T(__is_trivial(EmptyUnion))]; }
2069 { int arr[T(__is_trivial(Union))]; }
2070 { int arr[T(__is_trivial(Derives))]; }
2071 { int arr[T(__is_trivial(DerivesAr))]; }
2072 { int arr[T(__is_trivial(DerivesArNB))]; }
2073 { int arr[T(__is_trivial(DerivesEmpty))]; }
2074 { int arr[T(__is_trivial(HasFunc))]; }
2075 { int arr[T(__is_trivial(HasOp))]; }
2076 { int arr[T(__is_trivial(HasConv))]; }
2077 { int arr[T(__is_trivial(HasAssign))]; }
2078 { int arr[T(__is_trivial(HasAnonymousUnion))]; }
2079 { int arr[T(__is_trivial(HasPriv))]; }
2080 { int arr[T(__is_trivial(HasProt))]; }
2081 { int arr[T(__is_trivial(DerivesHasPriv))]; }
2082 { int arr[T(__is_trivial(DerivesHasProt))]; }
2083 { int arr[T(__is_trivial(Vector))]; }
2084 { int arr[T(__is_trivial(VectorExt))]; }
2086 { int arr[F(__is_trivial(HasCons))]; }
2087 { int arr[F(__is_trivial(HasCopyAssign))]; }
2088 { int arr[F(__is_trivial(HasMoveAssign))]; }
2089 { int arr[F(__is_trivial(HasDest))]; }
2090 { int arr[F(__is_trivial(HasRef))]; }
2091 { int arr[F(__is_trivial(HasNonPOD))]; }
2092 { int arr[F(__is_trivial(HasVirt))]; }
2093 { int arr[F(__is_trivial(DerivesHasCons))]; }
2094 { int arr[F(__is_trivial(DerivesHasCopyAssign))]; }
2095 { int arr[F(__is_trivial(DerivesHasMoveAssign))]; }
2096 { int arr[F(__is_trivial(DerivesHasDest))]; }
2097 { int arr[F(__is_trivial(DerivesHasRef))]; }
2098 { int arr[F(__is_trivial(DerivesHasVirt))]; }
2099 { int arr[F(__is_trivial(void))]; }
2100 { int arr[F(__is_trivial(cvoid))]; }
2103 template<typename T> struct TriviallyConstructibleTemplate {};
2105 void trivial_checks()
2107 { int arr[T(__is_trivially_copyable(int))]; }
2108 { int arr[T(__is_trivially_copyable(Enum))]; }
2109 { int arr[T(__is_trivially_copyable(POD))]; }
2110 { int arr[T(__is_trivially_copyable(Int))]; }
2111 { int arr[T(__is_trivially_copyable(IntAr))]; }
2112 { int arr[T(__is_trivially_copyable(IntArNB))]; }
2113 { int arr[T(__is_trivially_copyable(Statics))]; }
2114 { int arr[T(__is_trivially_copyable(Empty))]; }
2115 { int arr[T(__is_trivially_copyable(EmptyUnion))]; }
2116 { int arr[T(__is_trivially_copyable(Union))]; }
2117 { int arr[T(__is_trivially_copyable(Derives))]; }
2118 { int arr[T(__is_trivially_copyable(DerivesAr))]; }
2119 { int arr[T(__is_trivially_copyable(DerivesArNB))]; }
2120 { int arr[T(__is_trivially_copyable(DerivesEmpty))]; }
2121 { int arr[T(__is_trivially_copyable(HasFunc))]; }
2122 { int arr[T(__is_trivially_copyable(HasOp))]; }
2123 { int arr[T(__is_trivially_copyable(HasConv))]; }
2124 { int arr[T(__is_trivially_copyable(HasAssign))]; }
2125 { int arr[T(__is_trivially_copyable(HasAnonymousUnion))]; }
2126 { int arr[T(__is_trivially_copyable(HasPriv))]; }
2127 { int arr[T(__is_trivially_copyable(HasProt))]; }
2128 { int arr[T(__is_trivially_copyable(DerivesHasPriv))]; }
2129 { int arr[T(__is_trivially_copyable(DerivesHasProt))]; }
2130 { int arr[T(__is_trivially_copyable(Vector))]; }
2131 { int arr[T(__is_trivially_copyable(VectorExt))]; }
2132 { int arr[T(__is_trivially_copyable(HasCons))]; }
2133 { int arr[T(__is_trivially_copyable(HasRef))]; }
2134 { int arr[T(__is_trivially_copyable(HasNonPOD))]; }
2135 { int arr[T(__is_trivially_copyable(DerivesHasCons))]; }
2136 { int arr[T(__is_trivially_copyable(DerivesHasRef))]; }
2137 { int arr[T(__is_trivially_copyable(NonTrivialDefault))]; }
2138 { int arr[T(__is_trivially_copyable(NonTrivialDefault[]))]; }
2139 { int arr[T(__is_trivially_copyable(NonTrivialDefault[3]))]; }
2141 { int arr[F(__is_trivially_copyable(HasCopyAssign))]; }
2142 { int arr[F(__is_trivially_copyable(HasMoveAssign))]; }
2143 { int arr[F(__is_trivially_copyable(HasDest))]; }
2144 { int arr[F(__is_trivially_copyable(HasVirt))]; }
2145 { int arr[F(__is_trivially_copyable(DerivesHasCopyAssign))]; }
2146 { int arr[F(__is_trivially_copyable(DerivesHasMoveAssign))]; }
2147 { int arr[F(__is_trivially_copyable(DerivesHasDest))]; }
2148 { int arr[F(__is_trivially_copyable(DerivesHasVirt))]; }
2149 { int arr[F(__is_trivially_copyable(void))]; }
2150 { int arr[F(__is_trivially_copyable(cvoid))]; }
2152 { int arr[T((__is_trivially_constructible(int)))]; }
2153 { int arr[T((__is_trivially_constructible(int, int)))]; }
2154 { int arr[T((__is_trivially_constructible(int, float)))]; }
2155 { int arr[T((__is_trivially_constructible(int, int&)))]; }
2156 { int arr[T((__is_trivially_constructible(int, const int&)))]; }
2157 { int arr[T((__is_trivially_constructible(int, int)))]; }
2158 { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign)))]; }
2159 { int arr[T((__is_trivially_constructible(HasCopyAssign, const HasCopyAssign&)))]; }
2160 { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign&&)))]; }
2161 { int arr[T((__is_trivially_constructible(HasCopyAssign)))]; }
2162 { int arr[T((__is_trivially_constructible(NonTrivialDefault,
2163 const NonTrivialDefault&)))]; }
2164 { int arr[T((__is_trivially_constructible(NonTrivialDefault,
2165 NonTrivialDefault&&)))]; }
2166 { int arr[T((__is_trivially_constructible(AllDefaulted)))]; }
2167 { int arr[T((__is_trivially_constructible(AllDefaulted,
2168 const AllDefaulted &)))]; }
2169 { int arr[T((__is_trivially_constructible(AllDefaulted,
2170 AllDefaulted &&)))]; }
2172 { int arr[F((__is_trivially_constructible(int, int*)))]; }
2173 { int arr[F((__is_trivially_constructible(NonTrivialDefault)))]; }
2174 { int arr[F((__is_trivially_constructible(ThreeArgCtor, int*, char*, int&)))]; }
2175 { int arr[F((__is_trivially_constructible(AllDeleted)))]; }
2176 { int arr[F((__is_trivially_constructible(AllDeleted,
2177 const AllDeleted &)))]; }
2178 { int arr[F((__is_trivially_constructible(AllDeleted,
2179 AllDeleted &&)))]; }
2180 { int arr[F((__is_trivially_constructible(ExtDefaulted)))]; }
2181 { int arr[F((__is_trivially_constructible(ExtDefaulted,
2182 const ExtDefaulted &)))]; }
2183 { int arr[F((__is_trivially_constructible(ExtDefaulted,
2184 ExtDefaulted &&)))]; }
2186 { int arr[T((__is_trivially_constructible(TriviallyConstructibleTemplate<int>)))]; }
2187 { int arr[F((__is_trivially_constructible(class_forward)))]; } // expected-error {{incomplete type 'class_forward' used in type trait expression}}
2188 { int arr[F((__is_trivially_constructible(class_forward[])))]; }
2189 { int arr[F((__is_trivially_constructible(void)))]; }
2191 { int arr[T((__is_trivially_assignable(int&, int)))]; }
2192 { int arr[T((__is_trivially_assignable(int&, int&)))]; }
2193 { int arr[T((__is_trivially_assignable(int&, int&&)))]; }
2194 { int arr[T((__is_trivially_assignable(int&, const int&)))]; }
2195 { int arr[T((__is_trivially_assignable(POD&, POD)))]; }
2196 { int arr[T((__is_trivially_assignable(POD&, POD&)))]; }
2197 { int arr[T((__is_trivially_assignable(POD&, POD&&)))]; }
2198 { int arr[T((__is_trivially_assignable(POD&, const POD&)))]; }
2199 { int arr[T((__is_trivially_assignable(int*&, int*)))]; }
2200 { int arr[T((__is_trivially_assignable(AllDefaulted,
2201 const AllDefaulted &)))]; }
2202 { int arr[T((__is_trivially_assignable(AllDefaulted,
2203 AllDefaulted &&)))]; }
2205 { int arr[F((__is_trivially_assignable(int*&, float*)))]; }
2206 { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign)))]; }
2207 { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign&)))]; }
2208 { int arr[F((__is_trivially_assignable(HasCopyAssign&, const HasCopyAssign&)))]; }
2209 { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign&&)))]; }
2210 { int arr[F((__is_trivially_assignable(TrivialMoveButNotCopy&,
2211 TrivialMoveButNotCopy&)))]; }
2212 { int arr[F((__is_trivially_assignable(TrivialMoveButNotCopy&,
2213 const TrivialMoveButNotCopy&)))]; }
2214 { int arr[F((__is_trivially_assignable(AllDeleted,
2215 const AllDeleted &)))]; }
2216 { int arr[F((__is_trivially_assignable(AllDeleted,
2217 AllDeleted &&)))]; }
2218 { int arr[F((__is_trivially_assignable(ExtDefaulted,
2219 const ExtDefaulted &)))]; }
2220 { int arr[F((__is_trivially_assignable(ExtDefaulted,
2221 ExtDefaulted &&)))]; }
2223 { int arr[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign&,
2224 HasDefaultTrivialCopyAssign&)))]; }
2225 { int arr[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign&,
2226 const HasDefaultTrivialCopyAssign&)))]; }
2227 { int arr[T((__is_trivially_assignable(TrivialMoveButNotCopy&,
2228 TrivialMoveButNotCopy)))]; }
2229 { int arr[T((__is_trivially_assignable(TrivialMoveButNotCopy&,
2230 TrivialMoveButNotCopy&&)))]; }
2231 { int arr[T((__is_trivially_assignable(int&, int)))]; }
2232 { int arr[T((__is_trivially_assignable(int&, int&)))]; }
2233 { int arr[T((__is_trivially_assignable(int&, int&&)))]; }
2234 { int arr[T((__is_trivially_assignable(int&, const int&)))]; }
2235 { int arr[T((__is_trivially_assignable(POD&, POD)))]; }
2236 { int arr[T((__is_trivially_assignable(POD&, POD&)))]; }
2237 { int arr[T((__is_trivially_assignable(POD&, POD&&)))]; }
2238 { int arr[T((__is_trivially_assignable(POD&, const POD&)))]; }
2239 { int arr[T((__is_trivially_assignable(int*&, int*)))]; }
2240 { int arr[T((__is_trivially_assignable(AllDefaulted,
2241 const AllDefaulted &)))]; }
2242 { int arr[T((__is_trivially_assignable(AllDefaulted,
2243 AllDefaulted &&)))]; }
2245 { int arr[F((__is_assignable(int *&, float *)))]; }
2246 { int arr[T((__is_assignable(HasCopyAssign &, HasCopyAssign)))]; }
2247 { int arr[T((__is_assignable(HasCopyAssign &, HasCopyAssign &)))]; }
2248 { int arr[T((__is_assignable(HasCopyAssign &, const HasCopyAssign &)))]; }
2249 { int arr[T((__is_assignable(HasCopyAssign &, HasCopyAssign &&)))]; }
2250 { int arr[T((__is_assignable(TrivialMoveButNotCopy &,
2251 TrivialMoveButNotCopy &)))]; }
2252 { int arr[T((__is_assignable(TrivialMoveButNotCopy &,
2253 const TrivialMoveButNotCopy &)))]; }
2254 { int arr[F((__is_assignable(AllDeleted,
2255 const AllDeleted &)))]; }
2256 { int arr[F((__is_assignable(AllDeleted,
2257 AllDeleted &&)))]; }
2258 { int arr[T((__is_assignable(ExtDefaulted,
2259 const ExtDefaulted &)))]; }
2260 { int arr[T((__is_assignable(ExtDefaulted,
2261 ExtDefaulted &&)))]; }
2263 { int arr[T((__is_assignable(HasDefaultTrivialCopyAssign &,
2264 HasDefaultTrivialCopyAssign &)))]; }
2265 { int arr[T((__is_assignable(HasDefaultTrivialCopyAssign &,
2266 const HasDefaultTrivialCopyAssign &)))]; }
2267 { int arr[T((__is_assignable(TrivialMoveButNotCopy &,
2268 TrivialMoveButNotCopy)))]; }
2269 { int arr[T((__is_assignable(TrivialMoveButNotCopy &,
2270 TrivialMoveButNotCopy &&)))]; }
2272 { int arr[T(__is_assignable(ACompleteType, ACompleteType))]; }
2273 { int arr[F(__is_assignable(AnIncompleteType, AnIncompleteType))]; } // expected-error {{incomplete type}}
2274 { int arr[F(__is_assignable(AnIncompleteType[], AnIncompleteType[]))]; }
2275 { int arr[F(__is_assignable(AnIncompleteType[1], AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2276 { int arr[F(__is_assignable(void, void))]; }
2277 { int arr[F(__is_assignable(const volatile void, const volatile void))]; }
2280 void constructible_checks() {
2281 { int arr[T(__is_constructible(HasNoThrowConstructorWithArgs))]; }
2282 { int arr[F(__is_nothrow_constructible(HasNoThrowConstructorWithArgs))]; } // MSVC doesn't look into default args and gets this wrong.
2284 { int arr[T(__is_constructible(HasNoThrowConstructorWithArgs, HasCons))]; }
2285 { int arr[T(__is_nothrow_constructible(HasNoThrowConstructorWithArgs, HasCons))]; }
2287 { int arr[T(__is_constructible(NonTrivialDefault))]; }
2288 { int arr[F(__is_nothrow_constructible(NonTrivialDefault))]; }
2290 { int arr[T(__is_constructible(int))]; }
2291 { int arr[T(__is_nothrow_constructible(int))]; }
2293 { int arr[F(__is_constructible(NonPOD))]; }
2294 { int arr[F(__is_nothrow_constructible(NonPOD))]; }
2296 { int arr[T(__is_constructible(NonPOD, int))]; }
2297 { int arr[F(__is_nothrow_constructible(NonPOD, int))]; }
2299 // PR19178
2300 { int arr[F(__is_constructible(Abstract))]; }
2301 { int arr[F(__is_nothrow_constructible(Abstract))]; }
2303 // PR20228
2304 { int arr[T(__is_constructible(VariadicCtor,
2305 int, int, int, int, int, int, int, int, int))]; }
2307 // PR25513
2308 { int arr[F(__is_constructible(int(int)))]; }
2309 { int arr[T(__is_constructible(int const &, long))]; }
2311 { int arr[T(__is_constructible(ACompleteType))]; }
2312 { int arr[T(__is_nothrow_constructible(ACompleteType))]; }
2313 { int arr[F(__is_constructible(AnIncompleteType))]; } // expected-error {{incomplete type}}
2314 { int arr[F(__is_nothrow_constructible(AnIncompleteType))]; } // expected-error {{incomplete type}}
2315 { int arr[F(__is_constructible(AnIncompleteType[]))]; }
2316 { int arr[F(__is_nothrow_constructible(AnIncompleteType[]))]; }
2317 { int arr[F(__is_constructible(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2318 { int arr[F(__is_nothrow_constructible(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2319 { int arr[F(__is_constructible(void))]; }
2320 { int arr[F(__is_nothrow_constructible(void))]; }
2321 { int arr[F(__is_constructible(const volatile void))]; }
2322 { int arr[F(__is_nothrow_constructible(const volatile void))]; }
2325 // Instantiation of __is_trivially_constructible
2326 template<typename T, typename ...Args>
2327 struct is_trivially_constructible {
2328 static const bool value = __is_trivially_constructible(T, Args...);
2331 void is_trivially_constructible_test() {
2332 { int arr[T((is_trivially_constructible<int>::value))]; }
2333 { int arr[T((is_trivially_constructible<int, int>::value))]; }
2334 { int arr[T((is_trivially_constructible<int, float>::value))]; }
2335 { int arr[T((is_trivially_constructible<int, int&>::value))]; }
2336 { int arr[T((is_trivially_constructible<int, const int&>::value))]; }
2337 { int arr[T((is_trivially_constructible<int, int>::value))]; }
2338 { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign>::value))]; }
2339 { int arr[T((is_trivially_constructible<HasCopyAssign, const HasCopyAssign&>::value))]; }
2340 { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign&&>::value))]; }
2341 { int arr[T((is_trivially_constructible<HasCopyAssign>::value))]; }
2342 { int arr[T((is_trivially_constructible<NonTrivialDefault,
2343 const NonTrivialDefault&>::value))]; }
2344 { int arr[T((is_trivially_constructible<NonTrivialDefault,
2345 NonTrivialDefault&&>::value))]; }
2347 { int arr[F((is_trivially_constructible<int, int*>::value))]; }
2348 { int arr[F((is_trivially_constructible<NonTrivialDefault>::value))]; }
2349 { int arr[F((is_trivially_constructible<ThreeArgCtor, int*, char*, int&>::value))]; }
2350 { int arr[F((is_trivially_constructible<Abstract>::value))]; } // PR19178
2352 { int arr[T(__is_trivially_constructible(ACompleteType))]; }
2353 { int arr[F(__is_trivially_constructible(AnIncompleteType))]; } // expected-error {{incomplete type}}
2354 { int arr[F(__is_trivially_constructible(AnIncompleteType[]))]; }
2355 { int arr[F(__is_trivially_constructible(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2356 { int arr[F(__is_trivially_constructible(void))]; }
2357 { int arr[F(__is_trivially_constructible(const volatile void))]; }
2360 template <class T, class RefType = T &>
2361 struct ConvertsToRef {
2362 operator RefType() const { return static_cast<RefType>(obj); }
2363 mutable T obj = 42;
2366 void reference_binds_to_temporary_checks() {
2367 { int arr[F((__reference_binds_to_temporary(int &, int &)))]; }
2368 { int arr[F((__reference_binds_to_temporary(int &, int &&)))]; }
2370 { int arr[F((__reference_binds_to_temporary(int const &, int &)))]; }
2371 { int arr[F((__reference_binds_to_temporary(int const &, int const &)))]; }
2372 { int arr[F((__reference_binds_to_temporary(int const &, int &&)))]; }
2374 { int arr[F((__reference_binds_to_temporary(int &, long &)))]; } // doesn't construct
2375 { int arr[T((__reference_binds_to_temporary(int const &, long &)))]; }
2376 { int arr[T((__reference_binds_to_temporary(int const &, long &&)))]; }
2377 { int arr[T((__reference_binds_to_temporary(int &&, long &)))]; }
2379 using LRef = ConvertsToRef<int, int &>;
2380 using RRef = ConvertsToRef<int, int &&>;
2381 using CLRef = ConvertsToRef<int, const int &>;
2382 using LongRef = ConvertsToRef<long, long &>;
2383 { int arr[T((__is_constructible(int &, LRef)))]; }
2384 { int arr[F((__reference_binds_to_temporary(int &, LRef)))]; }
2386 { int arr[T((__is_constructible(int &&, RRef)))]; }
2387 { int arr[F((__reference_binds_to_temporary(int &&, RRef)))]; }
2389 { int arr[T((__is_constructible(int const &, CLRef)))]; }
2390 { int arr[F((__reference_binds_to_temporary(int &&, CLRef)))]; }
2392 { int arr[T((__is_constructible(int const &, LongRef)))]; }
2393 { int arr[T((__reference_binds_to_temporary(int const &, LongRef)))]; }
2395 // Test that it doesn't accept non-reference types as input.
2396 { int arr[F((__reference_binds_to_temporary(int, long)))]; }
2398 { int arr[T((__reference_binds_to_temporary(const int &, long)))]; }
2401 void array_rank() {
2402 int t01[T(__array_rank(IntAr) == 1)];
2403 int t02[T(__array_rank(ConstIntArAr) == 2)];
2406 void array_extent() {
2407 int t01[T(__array_extent(IntAr, 0) == 10)];
2408 int t02[T(__array_extent(ConstIntArAr, 0) == 4)];
2409 int t03[T(__array_extent(ConstIntArAr, 1) == 10)];
2412 void is_destructible_test() {
2413 { int arr[T(__is_destructible(int))]; }
2414 { int arr[T(__is_destructible(int[2]))]; }
2415 { int arr[F(__is_destructible(int[]))]; }
2416 { int arr[F(__is_destructible(void))]; }
2417 { int arr[T(__is_destructible(int &))]; }
2418 { int arr[T(__is_destructible(HasDest))]; }
2419 { int arr[F(__is_destructible(AllPrivate))]; }
2420 { int arr[T(__is_destructible(SuperNonTrivialStruct))]; }
2421 { int arr[T(__is_destructible(AllDefaulted))]; }
2422 { int arr[F(__is_destructible(AllDeleted))]; }
2423 { int arr[T(__is_destructible(ThrowingDtor))]; }
2424 { int arr[T(__is_destructible(NoThrowDtor))]; }
2426 { int arr[T(__is_destructible(ACompleteType))]; }
2427 { int arr[F(__is_destructible(AnIncompleteType))]; } // expected-error {{incomplete type}}
2428 { int arr[F(__is_destructible(AnIncompleteType[]))]; }
2429 { int arr[F(__is_destructible(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2430 { int arr[F(__is_destructible(void))]; }
2431 { int arr[F(__is_destructible(const volatile void))]; }
2434 void is_nothrow_destructible_test() {
2435 { int arr[T(__is_nothrow_destructible(int))]; }
2436 { int arr[T(__is_nothrow_destructible(int[2]))]; }
2437 { int arr[F(__is_nothrow_destructible(int[]))]; }
2438 { int arr[F(__is_nothrow_destructible(void))]; }
2439 { int arr[T(__is_nothrow_destructible(int &))]; }
2440 { int arr[T(__is_nothrow_destructible(HasDest))]; }
2441 { int arr[F(__is_nothrow_destructible(AllPrivate))]; }
2442 { int arr[T(__is_nothrow_destructible(SuperNonTrivialStruct))]; }
2443 { int arr[T(__is_nothrow_destructible(AllDefaulted))]; }
2444 { int arr[F(__is_nothrow_destructible(AllDeleted))]; }
2445 { int arr[F(__is_nothrow_destructible(ThrowingDtor))]; }
2446 { int arr[T(__is_nothrow_destructible(NoExceptDtor))]; }
2447 { int arr[T(__is_nothrow_destructible(NoThrowDtor))]; }
2449 { int arr[T(__is_nothrow_destructible(ACompleteType))]; }
2450 { int arr[F(__is_nothrow_destructible(AnIncompleteType))]; } // expected-error {{incomplete type}}
2451 { int arr[F(__is_nothrow_destructible(AnIncompleteType[]))]; }
2452 { int arr[F(__is_nothrow_destructible(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2453 { int arr[F(__is_nothrow_destructible(void))]; }
2454 { int arr[F(__is_nothrow_destructible(const volatile void))]; }
2457 void is_trivially_destructible_test() {
2458 { int arr[T(__is_trivially_destructible(int))]; }
2459 { int arr[T(__is_trivially_destructible(int[2]))]; }
2460 { int arr[F(__is_trivially_destructible(int[]))]; }
2461 { int arr[F(__is_trivially_destructible(void))]; }
2462 { int arr[T(__is_trivially_destructible(int &))]; }
2463 { int arr[F(__is_trivially_destructible(HasDest))]; }
2464 { int arr[F(__is_trivially_destructible(AllPrivate))]; }
2465 { int arr[F(__is_trivially_destructible(SuperNonTrivialStruct))]; }
2466 { int arr[T(__is_trivially_destructible(AllDefaulted))]; }
2467 { int arr[F(__is_trivially_destructible(AllDeleted))]; }
2468 { int arr[F(__is_trivially_destructible(ThrowingDtor))]; }
2469 { int arr[F(__is_trivially_destructible(NoThrowDtor))]; }
2471 { int arr[T(__is_trivially_destructible(ACompleteType))]; }
2472 { int arr[F(__is_trivially_destructible(AnIncompleteType))]; } // expected-error {{incomplete type}}
2473 { int arr[F(__is_trivially_destructible(AnIncompleteType[]))]; }
2474 { int arr[F(__is_trivially_destructible(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2475 { int arr[F(__is_trivially_destructible(void))]; }
2476 { int arr[F(__is_trivially_destructible(const volatile void))]; }
2479 // Instantiation of __has_unique_object_representations
2480 template <typename T>
2481 struct has_unique_object_representations {
2482 static const bool value = __has_unique_object_representations(T);
2485 static_assert(!has_unique_object_representations<void>::value, "void is never unique");
2486 static_assert(!has_unique_object_representations<const void>::value, "void is never unique");
2487 static_assert(!has_unique_object_representations<volatile void>::value, "void is never unique");
2488 static_assert(!has_unique_object_representations<const volatile void>::value, "void is never unique");
2490 static_assert(has_unique_object_representations<int>::value, "integrals are");
2491 static_assert(has_unique_object_representations<const int>::value, "integrals are");
2492 static_assert(has_unique_object_representations<volatile int>::value, "integrals are");
2493 static_assert(has_unique_object_representations<const volatile int>::value, "integrals are");
2495 static_assert(has_unique_object_representations<void *>::value, "as are pointers");
2496 static_assert(has_unique_object_representations<const void *>::value, "as are pointers");
2497 static_assert(has_unique_object_representations<volatile void *>::value, "are pointers");
2498 static_assert(has_unique_object_representations<const volatile void *>::value, "as are pointers");
2500 static_assert(has_unique_object_representations<int *>::value, "as are pointers");
2501 static_assert(has_unique_object_representations<const int *>::value, "as are pointers");
2502 static_assert(has_unique_object_representations<volatile int *>::value, "as are pointers");
2503 static_assert(has_unique_object_representations<const volatile int *>::value, "as are pointers");
2505 class C {};
2506 using FP = int (*)(int);
2507 using PMF = int (C::*)(int);
2508 using PMD = int C::*;
2510 static_assert(has_unique_object_representations<FP>::value, "even function pointers");
2511 static_assert(has_unique_object_representations<const FP>::value, "even function pointers");
2512 static_assert(has_unique_object_representations<volatile FP>::value, "even function pointers");
2513 static_assert(has_unique_object_representations<const volatile FP>::value, "even function pointers");
2515 static_assert(has_unique_object_representations<PMF>::value, "and pointer to members");
2516 static_assert(has_unique_object_representations<const PMF>::value, "and pointer to members");
2517 static_assert(has_unique_object_representations<volatile PMF>::value, "and pointer to members");
2518 static_assert(has_unique_object_representations<const volatile PMF>::value, "and pointer to members");
2520 static_assert(has_unique_object_representations<PMD>::value, "and pointer to members");
2521 static_assert(has_unique_object_representations<const PMD>::value, "and pointer to members");
2522 static_assert(has_unique_object_representations<volatile PMD>::value, "and pointer to members");
2523 static_assert(has_unique_object_representations<const volatile PMD>::value, "and pointer to members");
2525 static_assert(has_unique_object_representations<bool>::value, "yes, all integral types");
2526 static_assert(has_unique_object_representations<char>::value, "yes, all integral types");
2527 static_assert(has_unique_object_representations<signed char>::value, "yes, all integral types");
2528 static_assert(has_unique_object_representations<unsigned char>::value, "yes, all integral types");
2529 static_assert(has_unique_object_representations<short>::value, "yes, all integral types");
2530 static_assert(has_unique_object_representations<unsigned short>::value, "yes, all integral types");
2531 static_assert(has_unique_object_representations<int>::value, "yes, all integral types");
2532 static_assert(has_unique_object_representations<unsigned int>::value, "yes, all integral types");
2533 static_assert(has_unique_object_representations<long>::value, "yes, all integral types");
2534 static_assert(has_unique_object_representations<unsigned long>::value, "yes, all integral types");
2535 static_assert(has_unique_object_representations<long long>::value, "yes, all integral types");
2536 static_assert(has_unique_object_representations<unsigned long long>::value, "yes, all integral types");
2537 static_assert(has_unique_object_representations<wchar_t>::value, "yes, all integral types");
2538 static_assert(has_unique_object_representations<char16_t>::value, "yes, all integral types");
2539 static_assert(has_unique_object_representations<char32_t>::value, "yes, all integral types");
2541 static_assert(!has_unique_object_representations<void>::value, "but not void!");
2542 static_assert(!has_unique_object_representations<decltype(nullptr)>::value, "or nullptr_t");
2543 static_assert(!has_unique_object_representations<float>::value, "definitely not Floating Point");
2544 static_assert(!has_unique_object_representations<double>::value, "definitely not Floating Point");
2545 static_assert(!has_unique_object_representations<long double>::value, "definitely not Floating Point");
2547 struct NoPadding {
2548 int a;
2549 int b;
2552 static_assert(has_unique_object_representations<NoPadding>::value, "types without padding are");
2554 struct InheritsFromNoPadding : NoPadding {
2555 int c;
2556 int d;
2559 static_assert(has_unique_object_representations<InheritsFromNoPadding>::value, "types without padding are");
2561 struct VirtuallyInheritsFromNoPadding : virtual NoPadding {
2562 int c;
2563 int d;
2566 static_assert(!has_unique_object_representations<VirtuallyInheritsFromNoPadding>::value, "No virtual inheritance");
2568 struct Padding {
2569 char a;
2570 int b;
2573 //static_assert(!has_unique_object_representations<Padding>::value, "but not with padding");
2575 struct InheritsFromPadding : Padding {
2576 int c;
2577 int d;
2580 static_assert(!has_unique_object_representations<InheritsFromPadding>::value, "or its subclasses");
2582 struct TailPadding {
2583 int a;
2584 char b;
2587 static_assert(!has_unique_object_representations<TailPadding>::value, "even at the end");
2589 struct TinyStruct {
2590 char a;
2593 static_assert(has_unique_object_representations<TinyStruct>::value, "Should be no padding");
2595 struct InheritsFromTinyStruct : TinyStruct {
2596 int b;
2599 static_assert(!has_unique_object_representations<InheritsFromTinyStruct>::value, "Inherit causes padding");
2601 union NoPaddingUnion {
2602 int a;
2603 unsigned int b;
2606 static_assert(has_unique_object_representations<NoPaddingUnion>::value, "unions follow the same rules as structs");
2608 union PaddingUnion {
2609 int a;
2610 long long b;
2613 static_assert(!has_unique_object_representations<PaddingUnion>::value, "unions follow the same rules as structs");
2615 struct NotTriviallyCopyable {
2616 int x;
2617 NotTriviallyCopyable(const NotTriviallyCopyable &) {}
2620 static_assert(!has_unique_object_representations<NotTriviallyCopyable>::value, "must be trivially copyable");
2622 struct HasNonUniqueMember {
2623 float x;
2626 static_assert(!has_unique_object_representations<HasNonUniqueMember>::value, "all members must be unique");
2628 enum ExampleEnum { xExample,
2629 yExample };
2630 enum LLEnum : long long { xLongExample,
2631 yLongExample };
2633 static_assert(has_unique_object_representations<ExampleEnum>::value, "Enums are integrals, so unique!");
2634 static_assert(has_unique_object_representations<LLEnum>::value, "Enums are integrals, so unique!");
2636 enum class ExampleEnumClass { xExample,
2637 yExample };
2638 enum class LLEnumClass : long long { xLongExample,
2639 yLongExample };
2641 static_assert(has_unique_object_representations<ExampleEnumClass>::value, "Enums are integrals, so unique!");
2642 static_assert(has_unique_object_representations<LLEnumClass>::value, "Enums are integrals, so unique!");
2644 // because references aren't trivially copyable.
2645 static_assert(!has_unique_object_representations<int &>::value, "No references!");
2646 static_assert(!has_unique_object_representations<const int &>::value, "No references!");
2647 static_assert(!has_unique_object_representations<volatile int &>::value, "No references!");
2648 static_assert(!has_unique_object_representations<const volatile int &>::value, "No references!");
2649 static_assert(!has_unique_object_representations<Empty>::value, "No empty types!");
2650 static_assert(!has_unique_object_representations<EmptyUnion>::value, "No empty types!");
2652 class Compressed : Empty {
2653 int x;
2656 static_assert(has_unique_object_representations<Compressed>::value, "But inheriting from one is ok");
2658 class EmptyInheritor : Compressed {};
2660 static_assert(has_unique_object_representations<EmptyInheritor>::value, "As long as the base has items, empty is ok");
2662 class Dynamic {
2663 virtual void A();
2664 int i;
2667 static_assert(!has_unique_object_representations<Dynamic>::value, "Dynamic types are not valid");
2669 class InheritsDynamic : Dynamic {
2670 int j;
2673 static_assert(!has_unique_object_representations<InheritsDynamic>::value, "Dynamic types are not valid");
2675 static_assert(has_unique_object_representations<int[42]>::value, "Arrays are fine, as long as their value type is");
2676 static_assert(has_unique_object_representations<int[]>::value, "Arrays are fine, as long as their value type is");
2677 static_assert(has_unique_object_representations<int[][42]>::value, "Arrays are fine, as long as their value type is");
2678 static_assert(!has_unique_object_representations<double[42]>::value, "So no array of doubles!");
2679 static_assert(!has_unique_object_representations<double[]>::value, "So no array of doubles!");
2680 static_assert(!has_unique_object_representations<double[][42]>::value, "So no array of doubles!");
2682 struct __attribute__((aligned(16))) WeirdAlignment {
2683 int i;
2685 union __attribute__((aligned(16))) WeirdAlignmentUnion {
2686 int i;
2688 static_assert(!has_unique_object_representations<WeirdAlignment>::value, "Alignment causes padding");
2689 static_assert(!has_unique_object_representations<WeirdAlignmentUnion>::value, "Alignment causes padding");
2690 static_assert(!has_unique_object_representations<WeirdAlignment[42]>::value, "Also no arrays that have padding");
2692 static_assert(!has_unique_object_representations<int(int)>::value, "Functions are not unique");
2693 static_assert(!has_unique_object_representations<int(int) const>::value, "Functions are not unique");
2694 static_assert(!has_unique_object_representations<int(int) volatile>::value, "Functions are not unique");
2695 static_assert(!has_unique_object_representations<int(int) const volatile>::value, "Functions are not unique");
2696 static_assert(!has_unique_object_representations<int(int) &>::value, "Functions are not unique");
2697 static_assert(!has_unique_object_representations<int(int) const &>::value, "Functions are not unique");
2698 static_assert(!has_unique_object_representations<int(int) volatile &>::value, "Functions are not unique");
2699 static_assert(!has_unique_object_representations<int(int) const volatile &>::value, "Functions are not unique");
2700 static_assert(!has_unique_object_representations<int(int) &&>::value, "Functions are not unique");
2701 static_assert(!has_unique_object_representations<int(int) const &&>::value, "Functions are not unique");
2702 static_assert(!has_unique_object_representations<int(int) volatile &&>::value, "Functions are not unique");
2703 static_assert(!has_unique_object_representations<int(int) const volatile &&>::value, "Functions are not unique");
2705 static_assert(!has_unique_object_representations<int(int, ...)>::value, "Functions are not unique");
2706 static_assert(!has_unique_object_representations<int(int, ...) const>::value, "Functions are not unique");
2707 static_assert(!has_unique_object_representations<int(int, ...) volatile>::value, "Functions are not unique");
2708 static_assert(!has_unique_object_representations<int(int, ...) const volatile>::value, "Functions are not unique");
2709 static_assert(!has_unique_object_representations<int(int, ...) &>::value, "Functions are not unique");
2710 static_assert(!has_unique_object_representations<int(int, ...) const &>::value, "Functions are not unique");
2711 static_assert(!has_unique_object_representations<int(int, ...) volatile &>::value, "Functions are not unique");
2712 static_assert(!has_unique_object_representations<int(int, ...) const volatile &>::value, "Functions are not unique");
2713 static_assert(!has_unique_object_representations<int(int, ...) &&>::value, "Functions are not unique");
2714 static_assert(!has_unique_object_representations<int(int, ...) const &&>::value, "Functions are not unique");
2715 static_assert(!has_unique_object_representations<int(int, ...) volatile &&>::value, "Functions are not unique");
2716 static_assert(!has_unique_object_representations<int(int, ...) const volatile &&>::value, "Functions are not unique");
2718 void foo(){
2719 static auto lambda = []() {};
2720 static_assert(!has_unique_object_representations<decltype(lambda)>::value, "Lambdas follow struct rules");
2721 int i;
2722 static auto lambda2 = [i]() {};
2723 static_assert(has_unique_object_representations<decltype(lambda2)>::value, "Lambdas follow struct rules");
2726 struct PaddedBitfield {
2727 char c : 6;
2728 char d : 1;
2731 struct UnPaddedBitfield {
2732 char c : 6;
2733 char d : 2;
2736 struct AlignedPaddedBitfield {
2737 char c : 6;
2738 __attribute__((aligned(1)))
2739 char d : 2;
2742 static_assert(!has_unique_object_representations<PaddedBitfield>::value, "Bitfield padding");
2743 static_assert(has_unique_object_representations<UnPaddedBitfield>::value, "Bitfield padding");
2744 static_assert(!has_unique_object_representations<AlignedPaddedBitfield>::value, "Bitfield padding");
2746 struct BoolBitfield {
2747 bool b : 8;
2750 static_assert(has_unique_object_representations<BoolBitfield>::value, "Bitfield bool");
2752 struct BoolBitfield2 {
2753 bool b : 16;
2756 static_assert(!has_unique_object_representations<BoolBitfield2>::value, "Bitfield bool");
2758 struct GreaterSizeBitfield {
2759 //expected-warning@+1 {{width of bit-field 'n'}}
2760 int n : 1024;
2763 static_assert(sizeof(GreaterSizeBitfield) == 128, "Bitfield Size");
2764 static_assert(!has_unique_object_representations<GreaterSizeBitfield>::value, "Bitfield padding");
2766 struct StructWithRef {
2767 int &I;
2770 static_assert(has_unique_object_representations<StructWithRef>::value, "References are still unique");
2772 struct NotUniqueBecauseTailPadding {
2773 int &r;
2774 char a;
2776 struct CanBeUniqueIfNoPadding : NotUniqueBecauseTailPadding {
2777 char b[7];
2780 static_assert(!has_unique_object_representations<NotUniqueBecauseTailPadding>::value,
2781 "non trivial");
2782 // Can be unique on Itanium, since the is child class' data is 'folded' into the
2783 // parent's tail padding.
2784 static_assert(sizeof(CanBeUniqueIfNoPadding) != 16 ||
2785 has_unique_object_representations<CanBeUniqueIfNoPadding>::value,
2786 "inherit from std layout");
2788 namespace ErrorType {
2789 struct S; //expected-note{{forward declaration of 'ErrorType::S'}}
2791 struct T {
2792 S t; //expected-error{{field has incomplete type 'ErrorType::S'}}
2794 bool b = __has_unique_object_representations(T);
2797 namespace PR46209 {
2798 // Foo has both a trivial assignment operator and a non-trivial one.
2799 struct Foo {
2800 Foo &operator=(const Foo &) & { return *this; }
2801 Foo &operator=(const Foo &) && = default;
2804 // Bar's copy assignment calls Foo's non-trivial assignment.
2805 struct Bar {
2806 Foo foo;
2809 static_assert(!__is_trivially_assignable(Foo &, const Foo &), "");
2810 static_assert(!__is_trivially_assignable(Bar &, const Bar &), "");
2812 // Foo2 has both a trivial assignment operator and a non-trivial one.
2813 struct Foo2 {
2814 Foo2 &operator=(const Foo2 &) & = default;
2815 Foo2 &operator=(const Foo2 &) && { return *this; }
2818 // Bar2's copy assignment calls Foo2's trivial assignment.
2819 struct Bar2 {
2820 Foo2 foo;
2823 static_assert(__is_trivially_assignable(Foo2 &, const Foo2 &), "");
2824 static_assert(__is_trivially_assignable(Bar2 &, const Bar2 &), "");
2827 namespace ConstClass {
2828 struct A {
2829 A &operator=(const A&) = default;
2831 struct B {
2832 const A a;
2834 static_assert(!__is_trivially_assignable(B&, const B&), "");
2837 namespace type_trait_expr_numargs_overflow {
2838 // Make sure that TypeTraitExpr can store 16 bits worth of arguments.
2839 #define T4(X) X,X,X,X
2840 #define T16(X) T4(X),T4(X),T4(X),T4(X)
2841 #define T64(X) T16(X),T16(X),T16(X),T16(X)
2842 #define T256(X) T64(X),T64(X),T64(X),T64(X)
2843 #define T1024(X) T256(X),T256(X),T256(X),T256(X)
2844 #define T4096(X) T1024(X),T1024(X),T1024(X),T1024(X)
2845 #define T16384(X) T4096(X),T4096(X),T4096(X),T4096(X)
2846 #define T32768(X) T16384(X),T16384(X)
2847 void test() { (void) __is_constructible(int, T32768(int)); }
2848 #undef T4
2849 #undef T16
2850 #undef T64
2851 #undef T256
2852 #undef T1024
2853 #undef T4096
2854 #undef T16384
2855 #undef T32768
2856 } // namespace type_trait_expr_numargs_overflow