[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / type-traits.cpp
blobab2a9f74090a4fd4c933d4a43e596082c1abf643
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fblocks -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fblocks -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
3 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -fblocks -Wno-deprecated-builtins -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 enum class EnumClass { EV };
18 enum class SignedEnumClass : signed int {};
19 enum class UnsignedEnumClass : unsigned int {};
20 struct POD { Enum e; int i; float f; NonPOD* p; };
21 struct Empty {};
22 struct IncompleteStruct;
23 typedef Empty EmptyAr[10];
24 typedef Empty EmptyArNB[];
25 typedef Empty EmptyArMB[1][2];
26 typedef int Int;
27 typedef Int IntAr[10];
28 typedef Int IntArNB[];
29 class Statics { static int priv; static NonPOD np; };
30 union EmptyUnion {};
31 union IncompleteUnion; // expected-note {{forward declaration of 'IncompleteUnion'}}
32 union Union { int i; float f; };
33 struct HasFunc { void f (); };
34 struct HasOp { void operator *(); };
35 struct HasConv { operator int(); };
36 struct HasAssign { void operator =(int); };
38 struct HasAnonymousUnion {
39 union {
40 int i;
41 float f;
45 typedef int Vector __attribute__((vector_size(16)));
46 typedef int VectorExt __attribute__((ext_vector_type(4)));
48 using ComplexFloat = _Complex float;
49 using ComplexInt = _Complex int;
51 // Not PODs
52 typedef const void cvoid;
53 struct Derives : POD {};
54 typedef Derives DerivesAr[10];
55 typedef Derives DerivesArNB[];
56 struct DerivesEmpty : Empty {};
57 struct HasCons { HasCons(int); };
58 struct HasDefaultCons { HasDefaultCons() = default; };
59 struct HasExplicitDefaultCons { explicit HasExplicitDefaultCons() = default; };
60 struct HasInheritedCons : HasDefaultCons { using HasDefaultCons::HasDefaultCons; };
61 struct HasNoInheritedCons : HasCons {};
62 struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
63 struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
64 struct HasNoThrowMoveAssign {
65 HasNoThrowMoveAssign& operator=(
66 const HasNoThrowMoveAssign&&) throw(); };
67 struct HasNoExceptNoThrowMoveAssign {
68 HasNoExceptNoThrowMoveAssign& operator=(
69 const HasNoExceptNoThrowMoveAssign&&) noexcept;
71 struct HasThrowMoveAssign {
72 HasThrowMoveAssign& operator=(const HasThrowMoveAssign&&)
73 #if __cplusplus <= 201402L
74 throw(POD);
75 #else
76 noexcept(false);
77 #endif
81 struct HasNoExceptFalseMoveAssign {
82 HasNoExceptFalseMoveAssign& operator=(
83 const HasNoExceptFalseMoveAssign&&) noexcept(false); };
84 struct HasMoveCtor { HasMoveCtor(const HasMoveCtor&&); };
85 struct HasMemberMoveCtor { HasMoveCtor member; };
86 struct HasMemberMoveAssign { HasMoveAssign member; };
87 struct HasStaticMemberMoveCtor { static HasMoveCtor member; };
88 struct HasStaticMemberMoveAssign { static HasMoveAssign member; };
89 struct HasMemberThrowMoveAssign { HasThrowMoveAssign member; };
90 struct HasMemberNoExceptFalseMoveAssign {
91 HasNoExceptFalseMoveAssign member; };
92 struct HasMemberNoThrowMoveAssign { HasNoThrowMoveAssign member; };
93 struct HasMemberNoExceptNoThrowMoveAssign {
94 HasNoExceptNoThrowMoveAssign member; };
96 struct HasDefaultTrivialCopyAssign {
97 HasDefaultTrivialCopyAssign &operator=(
98 const HasDefaultTrivialCopyAssign&) = default;
100 struct TrivialMoveButNotCopy {
101 TrivialMoveButNotCopy &operator=(TrivialMoveButNotCopy&&) = default;
102 TrivialMoveButNotCopy &operator=(const TrivialMoveButNotCopy&);
104 struct NonTrivialDefault {
105 NonTrivialDefault();
108 struct HasDest { ~HasDest(); };
109 class HasPriv { int priv; };
110 class HasProt { protected: int prot; };
111 struct HasRef { int i; int& ref; HasRef() : i(0), ref(i) {} };
112 struct HasRefAggregate { int i; int& ref; };
113 struct HasNonPOD { NonPOD np; };
114 struct HasVirt { virtual void Virt() {}; };
115 typedef NonPOD NonPODAr[10];
116 typedef HasVirt VirtAr[10];
117 typedef NonPOD NonPODArNB[];
118 union NonPODUnion { int i; Derives n; };
119 struct DerivesHasCons : HasCons {};
120 struct DerivesHasCopyAssign : HasCopyAssign {};
121 struct DerivesHasMoveAssign : HasMoveAssign {};
122 struct DerivesHasDest : HasDest {};
123 struct DerivesHasPriv : HasPriv {};
124 struct DerivesHasProt : HasProt {};
125 struct DerivesHasRef : HasRef {};
126 struct DerivesHasVirt : HasVirt {};
127 struct DerivesHasMoveCtor : HasMoveCtor {};
129 struct HasNoThrowCopyAssign {
130 void operator =(const HasNoThrowCopyAssign&) throw();
132 struct HasMultipleCopyAssign {
133 void operator =(const HasMultipleCopyAssign&) throw();
134 void operator =(volatile HasMultipleCopyAssign&);
136 struct HasMultipleNoThrowCopyAssign {
137 void operator =(const HasMultipleNoThrowCopyAssign&) throw();
138 void operator =(volatile HasMultipleNoThrowCopyAssign&) throw();
141 struct HasNoThrowConstructor { HasNoThrowConstructor() throw(); };
142 struct HasNoThrowConstructorWithArgs {
143 HasNoThrowConstructorWithArgs(HasCons i = HasCons(0)) throw();
145 struct HasMultipleDefaultConstructor1 {
146 HasMultipleDefaultConstructor1() throw();
147 HasMultipleDefaultConstructor1(int i = 0);
149 struct HasMultipleDefaultConstructor2 {
150 HasMultipleDefaultConstructor2(int i = 0);
151 HasMultipleDefaultConstructor2() throw();
154 struct HasNoThrowCopy { HasNoThrowCopy(const HasNoThrowCopy&) throw(); };
155 struct HasMultipleCopy {
156 HasMultipleCopy(const HasMultipleCopy&) throw();
157 HasMultipleCopy(volatile HasMultipleCopy&);
159 struct HasMultipleNoThrowCopy {
160 HasMultipleNoThrowCopy(const HasMultipleNoThrowCopy&) throw();
161 HasMultipleNoThrowCopy(volatile HasMultipleNoThrowCopy&) throw();
164 struct HasVirtDest { virtual ~HasVirtDest(); };
165 struct DerivedVirtDest : HasVirtDest {};
166 typedef HasVirtDest VirtDestAr[1];
168 class AllPrivate {
169 AllPrivate() throw();
170 AllPrivate(const AllPrivate&) throw();
171 AllPrivate &operator=(const AllPrivate &) throw();
172 ~AllPrivate() throw();
175 struct ThreeArgCtor {
176 ThreeArgCtor(int*, char*, int);
179 struct VariadicCtor {
180 template<typename...T> VariadicCtor(T...);
183 struct ThrowingDtor {
184 ~ThrowingDtor()
185 #if __cplusplus <= 201402L
186 throw(int);
187 #else
188 noexcept(false);
189 #endif
192 struct NoExceptDtor {
193 ~NoExceptDtor() noexcept(true);
196 struct NoThrowDtor {
197 ~NoThrowDtor() throw();
200 struct ACompleteType {};
201 struct AnIncompleteType; // expected-note 1+ {{forward declaration of 'AnIncompleteType'}}
202 typedef AnIncompleteType AnIncompleteTypeAr[42];
203 typedef AnIncompleteType AnIncompleteTypeArNB[];
204 typedef AnIncompleteType AnIncompleteTypeArMB[1][10];
206 struct HasInClassInit {
207 int x = 42;
210 struct HasPrivateBase : private ACompleteType {};
211 struct HasProtectedBase : protected ACompleteType {};
212 struct HasVirtBase : virtual ACompleteType {};
214 void is_pod()
216 { int arr[T(__is_pod(int))]; }
217 { int arr[T(__is_pod(Enum))]; }
218 { int arr[T(__is_pod(POD))]; }
219 { int arr[T(__is_pod(Int))]; }
220 { int arr[T(__is_pod(IntAr))]; }
221 { int arr[T(__is_pod(Statics))]; }
222 { int arr[T(__is_pod(Empty))]; }
223 { int arr[T(__is_pod(EmptyUnion))]; }
224 { int arr[T(__is_pod(Union))]; }
225 { int arr[T(__is_pod(HasFunc))]; }
226 { int arr[T(__is_pod(HasOp))]; }
227 { int arr[T(__is_pod(HasConv))]; }
228 { int arr[T(__is_pod(HasAssign))]; }
229 { int arr[T(__is_pod(IntArNB))]; }
230 { int arr[T(__is_pod(HasAnonymousUnion))]; }
231 { int arr[T(__is_pod(Vector))]; }
232 { int arr[T(__is_pod(VectorExt))]; }
233 { int arr[T(__is_pod(Derives))]; }
234 { int arr[T(__is_pod(DerivesAr))]; }
235 { int arr[T(__is_pod(DerivesArNB))]; }
236 { int arr[T(__is_pod(DerivesEmpty))]; }
237 { int arr[T(__is_pod(HasPriv))]; }
238 { int arr[T(__is_pod(HasProt))]; }
239 { int arr[T(__is_pod(DerivesHasPriv))]; }
240 { int arr[T(__is_pod(DerivesHasProt))]; }
242 { int arr[F(__is_pod(HasCons))]; }
243 { int arr[F(__is_pod(HasCopyAssign))]; }
244 { int arr[F(__is_pod(HasMoveAssign))]; }
245 { int arr[F(__is_pod(HasDest))]; }
246 { int arr[F(__is_pod(HasRef))]; }
247 { int arr[F(__is_pod(HasVirt))]; }
248 { int arr[F(__is_pod(DerivesHasCons))]; }
249 { int arr[F(__is_pod(DerivesHasCopyAssign))]; }
250 { int arr[F(__is_pod(DerivesHasMoveAssign))]; }
251 { int arr[F(__is_pod(DerivesHasDest))]; }
252 { int arr[F(__is_pod(DerivesHasRef))]; }
253 { int arr[F(__is_pod(DerivesHasVirt))]; }
254 { int arr[F(__is_pod(NonPOD))]; }
255 { int arr[F(__is_pod(HasNonPOD))]; }
256 { int arr[F(__is_pod(NonPODAr))]; }
257 { int arr[F(__is_pod(NonPODArNB))]; }
258 { int arr[F(__is_pod(void))]; }
259 { int arr[F(__is_pod(cvoid))]; }
260 // { int arr[F(__is_pod(NonPODUnion))]; }
262 { int arr[T(__is_pod(ACompleteType))]; }
263 { int arr[F(__is_pod(AnIncompleteType))]; } // expected-error {{incomplete type}}
264 { int arr[F(__is_pod(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
265 { int arr[F(__is_pod(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
268 typedef Empty EmptyAr[10];
269 struct Bit0 { int : 0; };
270 struct Bit0Cons { int : 0; Bit0Cons(); };
271 struct AnonBitOnly { int : 3; };
272 struct BitOnly { int x : 3; };
273 struct DerivesVirt : virtual POD {};
275 void is_empty()
277 { int arr[T(__is_empty(Empty))]; }
278 { int arr[T(__is_empty(DerivesEmpty))]; }
279 { int arr[T(__is_empty(HasCons))]; }
280 { int arr[T(__is_empty(HasCopyAssign))]; }
281 { int arr[T(__is_empty(HasMoveAssign))]; }
282 { int arr[T(__is_empty(HasDest))]; }
283 { int arr[T(__is_empty(HasFunc))]; }
284 { int arr[T(__is_empty(HasOp))]; }
285 { int arr[T(__is_empty(HasConv))]; }
286 { int arr[T(__is_empty(HasAssign))]; }
287 { int arr[T(__is_empty(Bit0))]; }
288 { int arr[T(__is_empty(Bit0Cons))]; }
290 { int arr[F(__is_empty(Int))]; }
291 { int arr[F(__is_empty(POD))]; }
292 { int arr[F(__is_empty(EmptyUnion))]; }
293 { int arr[F(__is_empty(IncompleteUnion))]; }
294 { int arr[F(__is_empty(EmptyAr))]; }
295 { int arr[F(__is_empty(HasRef))]; }
296 { int arr[F(__is_empty(HasVirt))]; }
297 { int arr[F(__is_empty(AnonBitOnly))]; }
298 { int arr[F(__is_empty(BitOnly))]; }
299 { int arr[F(__is_empty(void))]; }
300 { int arr[F(__is_empty(IntArNB))]; }
301 { int arr[F(__is_empty(HasAnonymousUnion))]; }
302 // { int arr[F(__is_empty(DerivesVirt))]; }
304 { int arr[T(__is_empty(ACompleteType))]; }
305 { int arr[F(__is_empty(AnIncompleteType))]; } // expected-error {{incomplete type}}
306 { int arr[F(__is_empty(AnIncompleteType[]))]; }
307 { int arr[F(__is_empty(AnIncompleteType[1]))]; }
310 typedef Derives ClassType;
312 void is_class()
314 { int arr[T(__is_class(Derives))]; }
315 { int arr[T(__is_class(HasPriv))]; }
316 { int arr[T(__is_class(ClassType))]; }
317 { int arr[T(__is_class(HasAnonymousUnion))]; }
319 { int arr[F(__is_class(int))]; }
320 { int arr[F(__is_class(Enum))]; }
321 { int arr[F(__is_class(Int))]; }
322 { int arr[F(__is_class(IntAr))]; }
323 { int arr[F(__is_class(DerivesAr))]; }
324 { int arr[F(__is_class(Union))]; }
325 { int arr[F(__is_class(cvoid))]; }
326 { int arr[F(__is_class(IntArNB))]; }
329 typedef Union UnionAr[10];
330 typedef Union UnionType;
332 void is_union()
334 { int arr[T(__is_union(Union))]; }
335 { int arr[T(__is_union(UnionType))]; }
337 { int arr[F(__is_union(int))]; }
338 { int arr[F(__is_union(Enum))]; }
339 { int arr[F(__is_union(Int))]; }
340 { int arr[F(__is_union(IntAr))]; }
341 { int arr[F(__is_union(UnionAr))]; }
342 { int arr[F(__is_union(cvoid))]; }
343 { int arr[F(__is_union(IntArNB))]; }
344 { int arr[F(__is_union(HasAnonymousUnion))]; }
347 typedef Enum EnumType;
349 void is_enum()
351 { int arr[T(__is_enum(Enum))]; }
352 { int arr[T(__is_enum(EnumType))]; }
354 { int arr[F(__is_enum(int))]; }
355 { int arr[F(__is_enum(Union))]; }
356 { int arr[F(__is_enum(Int))]; }
357 { int arr[F(__is_enum(IntAr))]; }
358 { int arr[F(__is_enum(UnionAr))]; }
359 { int arr[F(__is_enum(Derives))]; }
360 { int arr[F(__is_enum(ClassType))]; }
361 { int arr[F(__is_enum(cvoid))]; }
362 { int arr[F(__is_enum(IntArNB))]; }
363 { int arr[F(__is_enum(HasAnonymousUnion))]; }
366 struct FinalClass final {
369 template<typename T>
370 struct PotentiallyFinal { };
372 template<typename T>
373 struct PotentiallyFinal<T*> final { };
375 template<>
376 struct PotentiallyFinal<int> final { };
378 struct SealedClass sealed {
381 template<typename T>
382 struct PotentiallySealed { };
384 template<typename T>
385 struct PotentiallySealed<T*> sealed { };
387 template<>
388 struct PotentiallySealed<int> sealed { };
390 void is_final()
392 { int arr[T(__is_final(SealedClass))]; }
393 { int arr[T(__is_final(PotentiallySealed<float*>))]; }
394 { int arr[T(__is_final(PotentiallySealed<int>))]; }
395 { int arr[T(__is_final(FinalClass))]; }
396 { int arr[T(__is_final(PotentiallyFinal<float*>))]; }
397 { int arr[T(__is_final(PotentiallyFinal<int>))]; }
399 { int arr[F(__is_final(int))]; }
400 { int arr[F(__is_final(Union))]; }
401 { int arr[F(__is_final(Int))]; }
402 { int arr[F(__is_final(IntAr))]; }
403 { int arr[F(__is_final(UnionAr))]; }
404 { int arr[F(__is_final(Derives))]; }
405 { int arr[F(__is_final(ClassType))]; }
406 { int arr[F(__is_final(cvoid))]; }
407 { int arr[F(__is_final(IntArNB))]; }
408 { int arr[F(__is_final(HasAnonymousUnion))]; }
409 { int arr[F(__is_final(PotentiallyFinal<float>))]; }
410 { int arr[F(__is_final(PotentiallySealed<float>))]; }
413 void is_sealed()
415 { int arr[T(__is_sealed(SealedClass))]; }
416 { int arr[T(__is_sealed(PotentiallySealed<float*>))]; }
417 { int arr[T(__is_sealed(PotentiallySealed<int>))]; }
418 { int arr[T(__is_sealed(FinalClass))]; }
419 { int arr[T(__is_sealed(PotentiallyFinal<float*>))]; }
420 { int arr[T(__is_sealed(PotentiallyFinal<int>))]; }
422 { int arr[F(__is_sealed(int))]; }
423 { int arr[F(__is_sealed(Union))]; }
424 { int arr[F(__is_sealed(Int))]; }
425 { int arr[F(__is_sealed(IntAr))]; }
426 { int arr[F(__is_sealed(UnionAr))]; }
427 { int arr[F(__is_sealed(Derives))]; }
428 { int arr[F(__is_sealed(ClassType))]; }
429 { int arr[F(__is_sealed(cvoid))]; }
430 { int arr[F(__is_sealed(IntArNB))]; }
431 { int arr[F(__is_sealed(HasAnonymousUnion))]; }
432 { int arr[F(__is_sealed(PotentiallyFinal<float>))]; }
433 { int arr[F(__is_sealed(PotentiallySealed<float>))]; }
436 typedef HasVirt Polymorph;
437 struct InheritPolymorph : Polymorph {};
439 void is_polymorphic()
441 { int arr[T(__is_polymorphic(Polymorph))]; }
442 { int arr[T(__is_polymorphic(InheritPolymorph))]; }
444 { int arr[F(__is_polymorphic(int))]; }
445 { int arr[F(__is_polymorphic(Union))]; }
446 { int arr[F(__is_polymorphic(IncompleteUnion))]; }
447 { int arr[F(__is_polymorphic(Int))]; }
448 { int arr[F(__is_polymorphic(IntAr))]; }
449 { int arr[F(__is_polymorphic(UnionAr))]; }
450 { int arr[F(__is_polymorphic(Derives))]; }
451 { int arr[F(__is_polymorphic(ClassType))]; }
452 { int arr[F(__is_polymorphic(Enum))]; }
453 { int arr[F(__is_polymorphic(cvoid))]; }
454 { int arr[F(__is_polymorphic(IntArNB))]; }
457 void is_integral()
459 int t01[T(__is_integral(bool))];
460 int t02[T(__is_integral(char))];
461 int t03[T(__is_integral(signed char))];
462 int t04[T(__is_integral(unsigned char))];
463 //int t05[T(__is_integral(char16_t))];
464 //int t06[T(__is_integral(char32_t))];
465 int t07[T(__is_integral(wchar_t))];
466 int t08[T(__is_integral(short))];
467 int t09[T(__is_integral(unsigned short))];
468 int t10[T(__is_integral(int))];
469 int t11[T(__is_integral(unsigned int))];
470 int t12[T(__is_integral(long))];
471 int t13[T(__is_integral(unsigned long))];
473 int t21[F(__is_integral(float))];
474 int t22[F(__is_integral(double))];
475 int t23[F(__is_integral(long double))];
476 int t24[F(__is_integral(Union))];
477 int t25[F(__is_integral(UnionAr))];
478 int t26[F(__is_integral(Derives))];
479 int t27[F(__is_integral(ClassType))];
480 int t28[F(__is_integral(Enum))];
481 int t29[F(__is_integral(void))];
482 int t30[F(__is_integral(cvoid))];
483 int t31[F(__is_integral(IntArNB))];
486 void is_floating_point()
488 int t01[T(__is_floating_point(float))];
489 int t02[T(__is_floating_point(double))];
490 int t03[T(__is_floating_point(long double))];
492 int t11[F(__is_floating_point(bool))];
493 int t12[F(__is_floating_point(char))];
494 int t13[F(__is_floating_point(signed char))];
495 int t14[F(__is_floating_point(unsigned char))];
496 //int t15[F(__is_floating_point(char16_t))];
497 //int t16[F(__is_floating_point(char32_t))];
498 int t17[F(__is_floating_point(wchar_t))];
499 int t18[F(__is_floating_point(short))];
500 int t19[F(__is_floating_point(unsigned short))];
501 int t20[F(__is_floating_point(int))];
502 int t21[F(__is_floating_point(unsigned int))];
503 int t22[F(__is_floating_point(long))];
504 int t23[F(__is_floating_point(unsigned long))];
505 int t24[F(__is_floating_point(Union))];
506 int t25[F(__is_floating_point(UnionAr))];
507 int t26[F(__is_floating_point(Derives))];
508 int t27[F(__is_floating_point(ClassType))];
509 int t28[F(__is_floating_point(Enum))];
510 int t29[F(__is_floating_point(void))];
511 int t30[F(__is_floating_point(cvoid))];
512 int t31[F(__is_floating_point(IntArNB))];
515 template <class T>
516 struct AggregateTemplate {
517 T value;
520 template <class T>
521 struct NonAggregateTemplate {
522 T value;
523 NonAggregateTemplate();
526 void is_aggregate()
528 constexpr bool TrueAfterCpp11 = __cplusplus > 201103L;
529 constexpr bool TrueAfterCpp14 = __cplusplus > 201402L;
531 __is_aggregate(AnIncompleteType); // expected-error {{incomplete type}}
532 __is_aggregate(AnIncompleteType[]); // expected-error {{incomplete type}}
533 __is_aggregate(AnIncompleteType[1]); // expected-error {{incomplete type}}
534 __is_aggregate(AnIncompleteTypeAr); // expected-error {{incomplete type}}
535 __is_aggregate(AnIncompleteTypeArNB); // expected-error {{incomplete type}}
536 __is_aggregate(AnIncompleteTypeArMB); // expected-error {{incomplete type}}
537 __is_aggregate(IncompleteUnion); // expected-error {{incomplete type}}
539 static_assert(!__is_aggregate(NonPOD), "");
540 static_assert(__is_aggregate(NonPODAr), "");
541 static_assert(__is_aggregate(NonPODArNB), "");
542 static_assert(__is_aggregate(NonPODArMB), "");
544 static_assert(!__is_aggregate(Enum), "");
545 static_assert(__is_aggregate(POD), "");
546 static_assert(__is_aggregate(Empty), "");
547 static_assert(__is_aggregate(EmptyAr), "");
548 static_assert(__is_aggregate(EmptyArNB), "");
549 static_assert(__is_aggregate(EmptyArMB), "");
550 static_assert(!__is_aggregate(void), "");
551 static_assert(!__is_aggregate(const volatile void), "");
552 static_assert(!__is_aggregate(int), "");
553 static_assert(__is_aggregate(IntAr), "");
554 static_assert(__is_aggregate(IntArNB), "");
555 static_assert(__is_aggregate(EmptyUnion), "");
556 static_assert(__is_aggregate(Union), "");
557 static_assert(__is_aggregate(Statics), "");
558 static_assert(__is_aggregate(HasFunc), "");
559 static_assert(__is_aggregate(HasOp), "");
560 static_assert(__is_aggregate(HasAssign), "");
561 static_assert(__is_aggregate(HasAnonymousUnion), "");
563 static_assert(__is_aggregate(Derives) == TrueAfterCpp14, "");
564 static_assert(__is_aggregate(DerivesAr), "");
565 static_assert(__is_aggregate(DerivesArNB), "");
566 static_assert(!__is_aggregate(HasCons), "");
567 static_assert(__is_aggregate(HasDefaultCons), "");
568 static_assert(!__is_aggregate(HasExplicitDefaultCons), "");
569 static_assert(!__is_aggregate(HasInheritedCons), "");
570 static_assert(__is_aggregate(HasNoInheritedCons) == TrueAfterCpp14, "");
571 static_assert(__is_aggregate(HasCopyAssign), "");
572 static_assert(!__is_aggregate(NonTrivialDefault), "");
573 static_assert(__is_aggregate(HasDest), "");
574 static_assert(!__is_aggregate(HasPriv), "");
575 static_assert(!__is_aggregate(HasProt), "");
576 static_assert(__is_aggregate(HasRefAggregate), "");
577 static_assert(__is_aggregate(HasNonPOD), "");
578 static_assert(!__is_aggregate(HasVirt), "");
579 static_assert(__is_aggregate(VirtAr), "");
580 static_assert(__is_aggregate(HasInClassInit) == TrueAfterCpp11, "");
581 static_assert(!__is_aggregate(HasPrivateBase), "");
582 static_assert(!__is_aggregate(HasProtectedBase), "");
583 static_assert(!__is_aggregate(HasVirtBase), "");
585 static_assert(__is_aggregate(AggregateTemplate<int>), "");
586 static_assert(!__is_aggregate(NonAggregateTemplate<int>), "");
588 static_assert(__is_aggregate(Vector), ""); // Extension supported by GCC and Clang
589 static_assert(__is_aggregate(VectorExt), "");
590 static_assert(__is_aggregate(ComplexInt), "");
591 static_assert(__is_aggregate(ComplexFloat), "");
594 void is_arithmetic()
596 int t01[T(__is_arithmetic(float))];
597 int t02[T(__is_arithmetic(double))];
598 int t03[T(__is_arithmetic(long double))];
599 int t11[T(__is_arithmetic(bool))];
600 int t12[T(__is_arithmetic(char))];
601 int t13[T(__is_arithmetic(signed char))];
602 int t14[T(__is_arithmetic(unsigned char))];
603 //int t15[T(__is_arithmetic(char16_t))];
604 //int t16[T(__is_arithmetic(char32_t))];
605 int t17[T(__is_arithmetic(wchar_t))];
606 int t18[T(__is_arithmetic(short))];
607 int t19[T(__is_arithmetic(unsigned short))];
608 int t20[T(__is_arithmetic(int))];
609 int t21[T(__is_arithmetic(unsigned int))];
610 int t22[T(__is_arithmetic(long))];
611 int t23[T(__is_arithmetic(unsigned long))];
613 int t24[F(__is_arithmetic(Union))];
614 int t25[F(__is_arithmetic(UnionAr))];
615 int t26[F(__is_arithmetic(Derives))];
616 int t27[F(__is_arithmetic(ClassType))];
617 int t28[F(__is_arithmetic(Enum))];
618 int t29[F(__is_arithmetic(void))];
619 int t30[F(__is_arithmetic(cvoid))];
620 int t31[F(__is_arithmetic(IntArNB))];
623 void is_complete_type()
625 int t01[T(__is_complete_type(float))];
626 int t02[T(__is_complete_type(double))];
627 int t03[T(__is_complete_type(long double))];
628 int t11[T(__is_complete_type(bool))];
629 int t12[T(__is_complete_type(char))];
630 int t13[T(__is_complete_type(signed char))];
631 int t14[T(__is_complete_type(unsigned char))];
632 //int t15[T(__is_complete_type(char16_t))];
633 //int t16[T(__is_complete_type(char32_t))];
634 int t17[T(__is_complete_type(wchar_t))];
635 int t18[T(__is_complete_type(short))];
636 int t19[T(__is_complete_type(unsigned short))];
637 int t20[T(__is_complete_type(int))];
638 int t21[T(__is_complete_type(unsigned int))];
639 int t22[T(__is_complete_type(long))];
640 int t23[T(__is_complete_type(unsigned long))];
641 int t24[T(__is_complete_type(ACompleteType))];
643 int t30[F(__is_complete_type(AnIncompleteType))];
646 void is_void()
648 int t01[T(__is_void(void))];
649 int t02[T(__is_void(cvoid))];
651 int t10[F(__is_void(float))];
652 int t11[F(__is_void(double))];
653 int t12[F(__is_void(long double))];
654 int t13[F(__is_void(bool))];
655 int t14[F(__is_void(char))];
656 int t15[F(__is_void(signed char))];
657 int t16[F(__is_void(unsigned char))];
658 int t17[F(__is_void(wchar_t))];
659 int t18[F(__is_void(short))];
660 int t19[F(__is_void(unsigned short))];
661 int t20[F(__is_void(int))];
662 int t21[F(__is_void(unsigned int))];
663 int t22[F(__is_void(long))];
664 int t23[F(__is_void(unsigned long))];
665 int t24[F(__is_void(Union))];
666 int t25[F(__is_void(UnionAr))];
667 int t26[F(__is_void(Derives))];
668 int t27[F(__is_void(ClassType))];
669 int t28[F(__is_void(Enum))];
670 int t29[F(__is_void(IntArNB))];
671 int t30[F(__is_void(void*))];
672 int t31[F(__is_void(cvoid*))];
675 void is_array()
677 int t01[T(__is_array(IntAr))];
678 int t02[T(__is_array(IntArNB))];
679 int t03[T(__is_array(UnionAr))];
681 int t10[F(__is_array(void))];
682 int t11[F(__is_array(cvoid))];
683 int t12[F(__is_array(float))];
684 int t13[F(__is_array(double))];
685 int t14[F(__is_array(long double))];
686 int t15[F(__is_array(bool))];
687 int t16[F(__is_array(char))];
688 int t17[F(__is_array(signed char))];
689 int t18[F(__is_array(unsigned char))];
690 int t19[F(__is_array(wchar_t))];
691 int t20[F(__is_array(short))];
692 int t21[F(__is_array(unsigned short))];
693 int t22[F(__is_array(int))];
694 int t23[F(__is_array(unsigned int))];
695 int t24[F(__is_array(long))];
696 int t25[F(__is_array(unsigned long))];
697 int t26[F(__is_array(Union))];
698 int t27[F(__is_array(Derives))];
699 int t28[F(__is_array(ClassType))];
700 int t29[F(__is_array(Enum))];
701 int t30[F(__is_array(void*))];
702 int t31[F(__is_array(cvoid*))];
705 template <typename T> void tmpl_func(T&) {}
707 template <typename T> struct type_wrapper {
708 typedef T type;
709 typedef T* ptrtype;
710 typedef T& reftype;
713 void is_function()
715 int t01[T(__is_function(type_wrapper<void(void)>::type))];
716 int t02[T(__is_function(typeof(tmpl_func<int>)))];
718 typedef void (*ptr_to_func_type)(void);
720 int t10[F(__is_function(void))];
721 int t11[F(__is_function(cvoid))];
722 int t12[F(__is_function(float))];
723 int t13[F(__is_function(double))];
724 int t14[F(__is_function(long double))];
725 int t15[F(__is_function(bool))];
726 int t16[F(__is_function(char))];
727 int t17[F(__is_function(signed char))];
728 int t18[F(__is_function(unsigned char))];
729 int t19[F(__is_function(wchar_t))];
730 int t20[F(__is_function(short))];
731 int t21[F(__is_function(unsigned short))];
732 int t22[F(__is_function(int))];
733 int t23[F(__is_function(unsigned int))];
734 int t24[F(__is_function(long))];
735 int t25[F(__is_function(unsigned long))];
736 int t26[F(__is_function(Union))];
737 int t27[F(__is_function(Derives))];
738 int t28[F(__is_function(ClassType))];
739 int t29[F(__is_function(Enum))];
740 int t30[F(__is_function(void*))];
741 int t31[F(__is_function(cvoid*))];
742 int t32[F(__is_function(void(*)()))];
743 int t33[F(__is_function(ptr_to_func_type))];
744 int t34[F(__is_function(type_wrapper<void(void)>::ptrtype))];
745 int t35[F(__is_function(type_wrapper<void(void)>::reftype))];
748 void is_reference()
750 int t01[T(__is_reference(int&))];
751 int t02[T(__is_reference(const int&))];
752 int t03[T(__is_reference(void *&))];
754 int t10[F(__is_reference(int))];
755 int t11[F(__is_reference(const int))];
756 int t12[F(__is_reference(void *))];
759 void is_lvalue_reference()
761 int t01[T(__is_lvalue_reference(int&))];
762 int t02[T(__is_lvalue_reference(void *&))];
763 int t03[T(__is_lvalue_reference(const int&))];
764 int t04[T(__is_lvalue_reference(void * const &))];
766 int t10[F(__is_lvalue_reference(int))];
767 int t11[F(__is_lvalue_reference(const int))];
768 int t12[F(__is_lvalue_reference(void *))];
771 #if __has_feature(cxx_rvalue_references)
773 void is_rvalue_reference()
775 int t01[T(__is_rvalue_reference(const int&&))];
776 int t02[T(__is_rvalue_reference(void * const &&))];
778 int t10[F(__is_rvalue_reference(int&))];
779 int t11[F(__is_rvalue_reference(void *&))];
780 int t12[F(__is_rvalue_reference(const int&))];
781 int t13[F(__is_rvalue_reference(void * const &))];
782 int t14[F(__is_rvalue_reference(int))];
783 int t15[F(__is_rvalue_reference(const int))];
784 int t16[F(__is_rvalue_reference(void *))];
787 #endif
789 void is_fundamental()
791 int t01[T(__is_fundamental(float))];
792 int t02[T(__is_fundamental(double))];
793 int t03[T(__is_fundamental(long double))];
794 int t11[T(__is_fundamental(bool))];
795 int t12[T(__is_fundamental(char))];
796 int t13[T(__is_fundamental(signed char))];
797 int t14[T(__is_fundamental(unsigned char))];
798 //int t15[T(__is_fundamental(char16_t))];
799 //int t16[T(__is_fundamental(char32_t))];
800 int t17[T(__is_fundamental(wchar_t))];
801 int t18[T(__is_fundamental(short))];
802 int t19[T(__is_fundamental(unsigned short))];
803 int t20[T(__is_fundamental(int))];
804 int t21[T(__is_fundamental(unsigned int))];
805 int t22[T(__is_fundamental(long))];
806 int t23[T(__is_fundamental(unsigned long))];
807 int t24[T(__is_fundamental(void))];
808 int t25[T(__is_fundamental(cvoid))];
809 int t26[T(__is_fundamental(decltype(nullptr)))];
811 int t30[F(__is_fundamental(Union))];
812 int t31[F(__is_fundamental(UnionAr))];
813 int t32[F(__is_fundamental(Derives))];
814 int t33[F(__is_fundamental(ClassType))];
815 int t34[F(__is_fundamental(Enum))];
816 int t35[F(__is_fundamental(IntArNB))];
819 void is_object()
821 int t01[T(__is_object(int))];
822 int t02[T(__is_object(int *))];
823 int t03[T(__is_object(void *))];
824 int t04[T(__is_object(Union))];
825 int t05[T(__is_object(UnionAr))];
826 int t06[T(__is_object(ClassType))];
827 int t07[T(__is_object(Enum))];
829 int t10[F(__is_object(type_wrapper<void(void)>::type))];
830 int t11[F(__is_object(int&))];
831 int t12[F(__is_object(void))];
834 void is_scalar()
836 int t01[T(__is_scalar(float))];
837 int t02[T(__is_scalar(double))];
838 int t03[T(__is_scalar(long double))];
839 int t04[T(__is_scalar(bool))];
840 int t05[T(__is_scalar(char))];
841 int t06[T(__is_scalar(signed char))];
842 int t07[T(__is_scalar(unsigned char))];
843 int t08[T(__is_scalar(wchar_t))];
844 int t09[T(__is_scalar(short))];
845 int t10[T(__is_scalar(unsigned short))];
846 int t11[T(__is_scalar(int))];
847 int t12[T(__is_scalar(unsigned int))];
848 int t13[T(__is_scalar(long))];
849 int t14[T(__is_scalar(unsigned long))];
850 int t15[T(__is_scalar(Enum))];
851 int t16[T(__is_scalar(void*))];
852 int t17[T(__is_scalar(cvoid*))];
854 int t20[F(__is_scalar(void))];
855 int t21[F(__is_scalar(cvoid))];
856 int t22[F(__is_scalar(Union))];
857 int t23[F(__is_scalar(UnionAr))];
858 int t24[F(__is_scalar(Derives))];
859 int t25[F(__is_scalar(ClassType))];
860 int t26[F(__is_scalar(IntArNB))];
863 struct StructWithMembers {
864 int member;
865 void method() {}
868 void is_compound()
870 int t01[T(__is_compound(void*))];
871 int t02[T(__is_compound(cvoid*))];
872 int t03[T(__is_compound(void (*)()))];
873 int t04[T(__is_compound(int StructWithMembers::*))];
874 int t05[T(__is_compound(void (StructWithMembers::*)()))];
875 int t06[T(__is_compound(int&))];
876 int t07[T(__is_compound(Union))];
877 int t08[T(__is_compound(UnionAr))];
878 int t09[T(__is_compound(Derives))];
879 int t10[T(__is_compound(ClassType))];
880 int t11[T(__is_compound(IntArNB))];
881 int t12[T(__is_compound(Enum))];
883 int t20[F(__is_compound(float))];
884 int t21[F(__is_compound(double))];
885 int t22[F(__is_compound(long double))];
886 int t23[F(__is_compound(bool))];
887 int t24[F(__is_compound(char))];
888 int t25[F(__is_compound(signed char))];
889 int t26[F(__is_compound(unsigned char))];
890 int t27[F(__is_compound(wchar_t))];
891 int t28[F(__is_compound(short))];
892 int t29[F(__is_compound(unsigned short))];
893 int t30[F(__is_compound(int))];
894 int t31[F(__is_compound(unsigned int))];
895 int t32[F(__is_compound(long))];
896 int t33[F(__is_compound(unsigned long))];
897 int t34[F(__is_compound(void))];
898 int t35[F(__is_compound(cvoid))];
901 void is_pointer()
903 StructWithMembers x;
905 int t01[T(__is_pointer(void*))];
906 int t02[T(__is_pointer(cvoid*))];
907 int t03[T(__is_pointer(cvoid*))];
908 int t04[T(__is_pointer(char*))];
909 int t05[T(__is_pointer(int*))];
910 int t06[T(__is_pointer(int**))];
911 int t07[T(__is_pointer(ClassType*))];
912 int t08[T(__is_pointer(Derives*))];
913 int t09[T(__is_pointer(Enum*))];
914 int t10[T(__is_pointer(IntArNB*))];
915 int t11[T(__is_pointer(Union*))];
916 int t12[T(__is_pointer(UnionAr*))];
917 int t13[T(__is_pointer(StructWithMembers*))];
918 int t14[T(__is_pointer(void (*)()))];
920 int t20[F(__is_pointer(void))];
921 int t21[F(__is_pointer(cvoid))];
922 int t22[F(__is_pointer(cvoid))];
923 int t23[F(__is_pointer(char))];
924 int t24[F(__is_pointer(int))];
925 int t25[F(__is_pointer(int))];
926 int t26[F(__is_pointer(ClassType))];
927 int t27[F(__is_pointer(Derives))];
928 int t28[F(__is_pointer(Enum))];
929 int t29[F(__is_pointer(IntArNB))];
930 int t30[F(__is_pointer(Union))];
931 int t31[F(__is_pointer(UnionAr))];
932 int t32[F(__is_pointer(StructWithMembers))];
933 int t33[F(__is_pointer(int StructWithMembers::*))];
934 int t34[F(__is_pointer(void (StructWithMembers::*) ()))];
937 void is_member_object_pointer()
939 StructWithMembers x;
941 int t01[T(__is_member_object_pointer(int StructWithMembers::*))];
943 int t10[F(__is_member_object_pointer(void (StructWithMembers::*) ()))];
944 int t11[F(__is_member_object_pointer(void*))];
945 int t12[F(__is_member_object_pointer(cvoid*))];
946 int t13[F(__is_member_object_pointer(cvoid*))];
947 int t14[F(__is_member_object_pointer(char*))];
948 int t15[F(__is_member_object_pointer(int*))];
949 int t16[F(__is_member_object_pointer(int**))];
950 int t17[F(__is_member_object_pointer(ClassType*))];
951 int t18[F(__is_member_object_pointer(Derives*))];
952 int t19[F(__is_member_object_pointer(Enum*))];
953 int t20[F(__is_member_object_pointer(IntArNB*))];
954 int t21[F(__is_member_object_pointer(Union*))];
955 int t22[F(__is_member_object_pointer(UnionAr*))];
956 int t23[F(__is_member_object_pointer(StructWithMembers*))];
957 int t24[F(__is_member_object_pointer(void))];
958 int t25[F(__is_member_object_pointer(cvoid))];
959 int t26[F(__is_member_object_pointer(cvoid))];
960 int t27[F(__is_member_object_pointer(char))];
961 int t28[F(__is_member_object_pointer(int))];
962 int t29[F(__is_member_object_pointer(int))];
963 int t30[F(__is_member_object_pointer(ClassType))];
964 int t31[F(__is_member_object_pointer(Derives))];
965 int t32[F(__is_member_object_pointer(Enum))];
966 int t33[F(__is_member_object_pointer(IntArNB))];
967 int t34[F(__is_member_object_pointer(Union))];
968 int t35[F(__is_member_object_pointer(UnionAr))];
969 int t36[F(__is_member_object_pointer(StructWithMembers))];
970 int t37[F(__is_member_object_pointer(void (*)()))];
973 void is_member_function_pointer()
975 StructWithMembers x;
977 int t01[T(__is_member_function_pointer(void (StructWithMembers::*) ()))];
979 int t10[F(__is_member_function_pointer(int StructWithMembers::*))];
980 int t11[F(__is_member_function_pointer(void*))];
981 int t12[F(__is_member_function_pointer(cvoid*))];
982 int t13[F(__is_member_function_pointer(cvoid*))];
983 int t14[F(__is_member_function_pointer(char*))];
984 int t15[F(__is_member_function_pointer(int*))];
985 int t16[F(__is_member_function_pointer(int**))];
986 int t17[F(__is_member_function_pointer(ClassType*))];
987 int t18[F(__is_member_function_pointer(Derives*))];
988 int t19[F(__is_member_function_pointer(Enum*))];
989 int t20[F(__is_member_function_pointer(IntArNB*))];
990 int t21[F(__is_member_function_pointer(Union*))];
991 int t22[F(__is_member_function_pointer(UnionAr*))];
992 int t23[F(__is_member_function_pointer(StructWithMembers*))];
993 int t24[F(__is_member_function_pointer(void))];
994 int t25[F(__is_member_function_pointer(cvoid))];
995 int t26[F(__is_member_function_pointer(cvoid))];
996 int t27[F(__is_member_function_pointer(char))];
997 int t28[F(__is_member_function_pointer(int))];
998 int t29[F(__is_member_function_pointer(int))];
999 int t30[F(__is_member_function_pointer(ClassType))];
1000 int t31[F(__is_member_function_pointer(Derives))];
1001 int t32[F(__is_member_function_pointer(Enum))];
1002 int t33[F(__is_member_function_pointer(IntArNB))];
1003 int t34[F(__is_member_function_pointer(Union))];
1004 int t35[F(__is_member_function_pointer(UnionAr))];
1005 int t36[F(__is_member_function_pointer(StructWithMembers))];
1006 int t37[F(__is_member_function_pointer(void (*)()))];
1009 void is_member_pointer()
1011 StructWithMembers x;
1013 int t01[T(__is_member_pointer(int StructWithMembers::*))];
1014 int t02[T(__is_member_pointer(void (StructWithMembers::*) ()))];
1016 int t10[F(__is_member_pointer(void*))];
1017 int t11[F(__is_member_pointer(cvoid*))];
1018 int t12[F(__is_member_pointer(cvoid*))];
1019 int t13[F(__is_member_pointer(char*))];
1020 int t14[F(__is_member_pointer(int*))];
1021 int t15[F(__is_member_pointer(int**))];
1022 int t16[F(__is_member_pointer(ClassType*))];
1023 int t17[F(__is_member_pointer(Derives*))];
1024 int t18[F(__is_member_pointer(Enum*))];
1025 int t19[F(__is_member_pointer(IntArNB*))];
1026 int t20[F(__is_member_pointer(Union*))];
1027 int t21[F(__is_member_pointer(UnionAr*))];
1028 int t22[F(__is_member_pointer(StructWithMembers*))];
1029 int t23[F(__is_member_pointer(void))];
1030 int t24[F(__is_member_pointer(cvoid))];
1031 int t25[F(__is_member_pointer(cvoid))];
1032 int t26[F(__is_member_pointer(char))];
1033 int t27[F(__is_member_pointer(int))];
1034 int t28[F(__is_member_pointer(int))];
1035 int t29[F(__is_member_pointer(ClassType))];
1036 int t30[F(__is_member_pointer(Derives))];
1037 int t31[F(__is_member_pointer(Enum))];
1038 int t32[F(__is_member_pointer(IntArNB))];
1039 int t33[F(__is_member_pointer(Union))];
1040 int t34[F(__is_member_pointer(UnionAr))];
1041 int t35[F(__is_member_pointer(StructWithMembers))];
1042 int t36[F(__is_member_pointer(void (*)()))];
1045 void is_const()
1047 int t01[T(__is_const(cvoid))];
1048 int t02[T(__is_const(const char))];
1049 int t03[T(__is_const(const int))];
1050 int t04[T(__is_const(const long))];
1051 int t05[T(__is_const(const short))];
1052 int t06[T(__is_const(const signed char))];
1053 int t07[T(__is_const(const wchar_t))];
1054 int t08[T(__is_const(const bool))];
1055 int t09[T(__is_const(const float))];
1056 int t10[T(__is_const(const double))];
1057 int t11[T(__is_const(const long double))];
1058 int t12[T(__is_const(const unsigned char))];
1059 int t13[T(__is_const(const unsigned int))];
1060 int t14[T(__is_const(const unsigned long long))];
1061 int t15[T(__is_const(const unsigned long))];
1062 int t16[T(__is_const(const unsigned short))];
1063 int t17[T(__is_const(const void))];
1064 int t18[T(__is_const(const ClassType))];
1065 int t19[T(__is_const(const Derives))];
1066 int t20[T(__is_const(const Enum))];
1067 int t21[T(__is_const(const IntArNB))];
1068 int t22[T(__is_const(const Union))];
1069 int t23[T(__is_const(const UnionAr))];
1071 int t30[F(__is_const(char))];
1072 int t31[F(__is_const(int))];
1073 int t32[F(__is_const(long))];
1074 int t33[F(__is_const(short))];
1075 int t34[F(__is_const(signed char))];
1076 int t35[F(__is_const(wchar_t))];
1077 int t36[F(__is_const(bool))];
1078 int t37[F(__is_const(float))];
1079 int t38[F(__is_const(double))];
1080 int t39[F(__is_const(long double))];
1081 int t40[F(__is_const(unsigned char))];
1082 int t41[F(__is_const(unsigned int))];
1083 int t42[F(__is_const(unsigned long long))];
1084 int t43[F(__is_const(unsigned long))];
1085 int t44[F(__is_const(unsigned short))];
1086 int t45[F(__is_const(void))];
1087 int t46[F(__is_const(ClassType))];
1088 int t47[F(__is_const(Derives))];
1089 int t48[F(__is_const(Enum))];
1090 int t49[F(__is_const(IntArNB))];
1091 int t50[F(__is_const(Union))];
1092 int t51[F(__is_const(UnionAr))];
1095 void is_volatile()
1097 int t02[T(__is_volatile(volatile char))];
1098 int t03[T(__is_volatile(volatile int))];
1099 int t04[T(__is_volatile(volatile long))];
1100 int t05[T(__is_volatile(volatile short))];
1101 int t06[T(__is_volatile(volatile signed char))];
1102 int t07[T(__is_volatile(volatile wchar_t))];
1103 int t08[T(__is_volatile(volatile bool))];
1104 int t09[T(__is_volatile(volatile float))];
1105 int t10[T(__is_volatile(volatile double))];
1106 int t11[T(__is_volatile(volatile long double))];
1107 int t12[T(__is_volatile(volatile unsigned char))];
1108 int t13[T(__is_volatile(volatile unsigned int))];
1109 int t14[T(__is_volatile(volatile unsigned long long))];
1110 int t15[T(__is_volatile(volatile unsigned long))];
1111 int t16[T(__is_volatile(volatile unsigned short))];
1112 int t17[T(__is_volatile(volatile void))];
1113 int t18[T(__is_volatile(volatile ClassType))];
1114 int t19[T(__is_volatile(volatile Derives))];
1115 int t20[T(__is_volatile(volatile Enum))];
1116 int t21[T(__is_volatile(volatile IntArNB))];
1117 int t22[T(__is_volatile(volatile Union))];
1118 int t23[T(__is_volatile(volatile UnionAr))];
1120 int t30[F(__is_volatile(char))];
1121 int t31[F(__is_volatile(int))];
1122 int t32[F(__is_volatile(long))];
1123 int t33[F(__is_volatile(short))];
1124 int t34[F(__is_volatile(signed char))];
1125 int t35[F(__is_volatile(wchar_t))];
1126 int t36[F(__is_volatile(bool))];
1127 int t37[F(__is_volatile(float))];
1128 int t38[F(__is_volatile(double))];
1129 int t39[F(__is_volatile(long double))];
1130 int t40[F(__is_volatile(unsigned char))];
1131 int t41[F(__is_volatile(unsigned int))];
1132 int t42[F(__is_volatile(unsigned long long))];
1133 int t43[F(__is_volatile(unsigned long))];
1134 int t44[F(__is_volatile(unsigned short))];
1135 int t45[F(__is_volatile(void))];
1136 int t46[F(__is_volatile(ClassType))];
1137 int t47[F(__is_volatile(Derives))];
1138 int t48[F(__is_volatile(Enum))];
1139 int t49[F(__is_volatile(IntArNB))];
1140 int t50[F(__is_volatile(Union))];
1141 int t51[F(__is_volatile(UnionAr))];
1144 struct TrivialStruct {
1145 int member;
1148 struct NonTrivialStruct {
1149 int member;
1150 NonTrivialStruct() {
1151 member = 0;
1155 struct SuperNonTrivialStruct {
1156 SuperNonTrivialStruct() { }
1157 ~SuperNonTrivialStruct() { }
1160 struct NonTCStruct {
1161 NonTCStruct(const NonTCStruct&) {}
1164 struct AllDefaulted {
1165 AllDefaulted() = default;
1166 AllDefaulted(const AllDefaulted &) = default;
1167 AllDefaulted(AllDefaulted &&) = default;
1168 AllDefaulted &operator=(const AllDefaulted &) = default;
1169 AllDefaulted &operator=(AllDefaulted &&) = default;
1170 ~AllDefaulted() = default;
1173 struct NoDefaultMoveAssignDueToUDCopyCtor {
1174 NoDefaultMoveAssignDueToUDCopyCtor(const NoDefaultMoveAssignDueToUDCopyCtor&);
1177 struct NoDefaultMoveAssignDueToUDCopyAssign {
1178 NoDefaultMoveAssignDueToUDCopyAssign& operator=(
1179 const NoDefaultMoveAssignDueToUDCopyAssign&);
1182 struct NoDefaultMoveAssignDueToDtor {
1183 ~NoDefaultMoveAssignDueToDtor();
1186 struct AllDeleted {
1187 AllDeleted() = delete;
1188 AllDeleted(const AllDeleted &) = delete;
1189 AllDeleted(AllDeleted &&) = delete;
1190 AllDeleted &operator=(const AllDeleted &) = delete;
1191 AllDeleted &operator=(AllDeleted &&) = delete;
1192 ~AllDeleted() = delete;
1195 struct ExtDefaulted {
1196 ExtDefaulted();
1197 ExtDefaulted(const ExtDefaulted &);
1198 ExtDefaulted(ExtDefaulted &&);
1199 ExtDefaulted &operator=(const ExtDefaulted &);
1200 ExtDefaulted &operator=(ExtDefaulted &&);
1201 ~ExtDefaulted();
1204 // Despite being defaulted, these functions are not trivial.
1205 ExtDefaulted::ExtDefaulted() = default;
1206 ExtDefaulted::ExtDefaulted(const ExtDefaulted &) = default;
1207 ExtDefaulted::ExtDefaulted(ExtDefaulted &&) = default;
1208 ExtDefaulted &ExtDefaulted::operator=(const ExtDefaulted &) = default;
1209 ExtDefaulted &ExtDefaulted::operator=(ExtDefaulted &&) = default;
1210 ExtDefaulted::~ExtDefaulted() = default;
1212 void is_trivial2()
1214 int t01[T(__is_trivial(char))];
1215 int t02[T(__is_trivial(int))];
1216 int t03[T(__is_trivial(long))];
1217 int t04[T(__is_trivial(short))];
1218 int t05[T(__is_trivial(signed char))];
1219 int t06[T(__is_trivial(wchar_t))];
1220 int t07[T(__is_trivial(bool))];
1221 int t08[T(__is_trivial(float))];
1222 int t09[T(__is_trivial(double))];
1223 int t10[T(__is_trivial(long double))];
1224 int t11[T(__is_trivial(unsigned char))];
1225 int t12[T(__is_trivial(unsigned int))];
1226 int t13[T(__is_trivial(unsigned long long))];
1227 int t14[T(__is_trivial(unsigned long))];
1228 int t15[T(__is_trivial(unsigned short))];
1229 int t16[T(__is_trivial(ClassType))];
1230 int t17[T(__is_trivial(Derives))];
1231 int t18[T(__is_trivial(Enum))];
1232 int t19[T(__is_trivial(IntAr))];
1233 int t20[T(__is_trivial(Union))];
1234 int t21[T(__is_trivial(UnionAr))];
1235 int t22[T(__is_trivial(TrivialStruct))];
1236 int t23[T(__is_trivial(AllDefaulted))];
1237 int t24[T(__is_trivial(AllDeleted))];
1239 int t30[F(__is_trivial(void))];
1240 int t31[F(__is_trivial(NonTrivialStruct))];
1241 int t32[F(__is_trivial(SuperNonTrivialStruct))];
1242 int t33[F(__is_trivial(NonTCStruct))];
1243 int t34[F(__is_trivial(ExtDefaulted))];
1245 int t40[T(__is_trivial(ACompleteType))];
1246 int t41[F(__is_trivial(AnIncompleteType))]; // expected-error {{incomplete type}}
1247 int t42[F(__is_trivial(AnIncompleteType[]))]; // expected-error {{incomplete type}}
1248 int t43[F(__is_trivial(AnIncompleteType[1]))]; // expected-error {{incomplete type}}
1249 int t44[F(__is_trivial(void))];
1250 int t45[F(__is_trivial(const volatile void))];
1253 void is_trivially_copyable2()
1255 int t01[T(__is_trivially_copyable(char))];
1256 int t02[T(__is_trivially_copyable(int))];
1257 int t03[T(__is_trivially_copyable(long))];
1258 int t04[T(__is_trivially_copyable(short))];
1259 int t05[T(__is_trivially_copyable(signed char))];
1260 int t06[T(__is_trivially_copyable(wchar_t))];
1261 int t07[T(__is_trivially_copyable(bool))];
1262 int t08[T(__is_trivially_copyable(float))];
1263 int t09[T(__is_trivially_copyable(double))];
1264 int t10[T(__is_trivially_copyable(long double))];
1265 int t11[T(__is_trivially_copyable(unsigned char))];
1266 int t12[T(__is_trivially_copyable(unsigned int))];
1267 int t13[T(__is_trivially_copyable(unsigned long long))];
1268 int t14[T(__is_trivially_copyable(unsigned long))];
1269 int t15[T(__is_trivially_copyable(unsigned short))];
1270 int t16[T(__is_trivially_copyable(ClassType))];
1271 int t17[T(__is_trivially_copyable(Derives))];
1272 int t18[T(__is_trivially_copyable(Enum))];
1273 int t19[T(__is_trivially_copyable(IntAr))];
1274 int t20[T(__is_trivially_copyable(Union))];
1275 int t21[T(__is_trivially_copyable(UnionAr))];
1276 int t22[T(__is_trivially_copyable(TrivialStruct))];
1277 int t23[T(__is_trivially_copyable(NonTrivialStruct))];
1278 int t24[T(__is_trivially_copyable(AllDefaulted))];
1279 int t25[T(__is_trivially_copyable(AllDeleted))];
1281 int t30[F(__is_trivially_copyable(void))];
1282 int t31[F(__is_trivially_copyable(SuperNonTrivialStruct))];
1283 int t32[F(__is_trivially_copyable(NonTCStruct))];
1284 int t33[F(__is_trivially_copyable(ExtDefaulted))];
1286 int t34[T(__is_trivially_copyable(const int))];
1287 int t35[T(__is_trivially_copyable(volatile int))];
1289 int t40[T(__is_trivially_copyable(ACompleteType))];
1290 int t41[F(__is_trivially_copyable(AnIncompleteType))]; // expected-error {{incomplete type}}
1291 int t42[F(__is_trivially_copyable(AnIncompleteType[]))]; // expected-error {{incomplete type}}
1292 int t43[F(__is_trivially_copyable(AnIncompleteType[1]))]; // expected-error {{incomplete type}}
1293 int t44[F(__is_trivially_copyable(void))];
1294 int t45[F(__is_trivially_copyable(const volatile void))];
1297 struct CStruct {
1298 int one;
1299 int two;
1302 struct CEmptyStruct {};
1304 struct CppEmptyStruct : CStruct {};
1305 struct CppStructStandard : CEmptyStruct {
1306 int three;
1307 int four;
1309 struct CppStructNonStandardByBase : CStruct {
1310 int three;
1311 int four;
1313 struct CppStructNonStandardByVirt : CStruct {
1314 virtual void method() {}
1316 struct CppStructNonStandardByMemb : CStruct {
1317 CppStructNonStandardByVirt member;
1319 struct CppStructNonStandardByProt : CStruct {
1320 int five;
1321 protected:
1322 int six;
1324 struct CppStructNonStandardByVirtBase : virtual CStruct {
1326 struct CppStructNonStandardBySameBase : CEmptyStruct {
1327 CEmptyStruct member;
1329 struct CppStructNonStandardBy2ndVirtBase : CEmptyStruct {
1330 CEmptyStruct member;
1333 void is_standard_layout()
1335 typedef const int ConstInt;
1336 typedef ConstInt ConstIntAr[4];
1337 typedef CppStructStandard CppStructStandardAr[4];
1339 int t01[T(__is_standard_layout(int))];
1340 int t02[T(__is_standard_layout(ConstInt))];
1341 int t03[T(__is_standard_layout(ConstIntAr))];
1342 int t04[T(__is_standard_layout(CStruct))];
1343 int t05[T(__is_standard_layout(CppStructStandard))];
1344 int t06[T(__is_standard_layout(CppStructStandardAr))];
1345 int t07[T(__is_standard_layout(Vector))];
1346 int t08[T(__is_standard_layout(VectorExt))];
1348 typedef CppStructNonStandardByBase CppStructNonStandardByBaseAr[4];
1350 int t10[F(__is_standard_layout(CppStructNonStandardByVirt))];
1351 int t11[F(__is_standard_layout(CppStructNonStandardByMemb))];
1352 int t12[F(__is_standard_layout(CppStructNonStandardByProt))];
1353 int t13[F(__is_standard_layout(CppStructNonStandardByVirtBase))];
1354 int t14[F(__is_standard_layout(CppStructNonStandardByBase))];
1355 int t15[F(__is_standard_layout(CppStructNonStandardByBaseAr))];
1356 int t16[F(__is_standard_layout(CppStructNonStandardBySameBase))];
1357 int t17[F(__is_standard_layout(CppStructNonStandardBy2ndVirtBase))];
1359 int t40[T(__is_standard_layout(ACompleteType))];
1360 int t41[F(__is_standard_layout(AnIncompleteType))]; // expected-error {{incomplete type}}
1361 int t42[F(__is_standard_layout(AnIncompleteType[]))]; // expected-error {{incomplete type}}
1362 int t43[F(__is_standard_layout(AnIncompleteType[1]))]; // expected-error {{incomplete type}}
1363 int t44[F(__is_standard_layout(void))];
1364 int t45[F(__is_standard_layout(const volatile void))];
1366 struct HasAnonEmptyBitfield { int : 0; };
1367 struct HasAnonBitfield { int : 4; };
1368 struct DerivesFromBitfield : HasAnonBitfield {};
1369 struct DerivesFromBitfieldWithBitfield : HasAnonBitfield { int : 5; };
1370 struct DerivesFromBitfieldTwice : DerivesFromBitfield, HasAnonEmptyBitfield {};
1372 int t50[T(__is_standard_layout(HasAnonEmptyBitfield))];
1373 int t51[T(__is_standard_layout(HasAnonBitfield))];
1374 int t52[T(__is_standard_layout(DerivesFromBitfield))];
1375 int t53[F(__is_standard_layout(DerivesFromBitfieldWithBitfield))];
1376 int t54[F(__is_standard_layout(DerivesFromBitfieldTwice))];
1378 struct Empty {};
1379 struct HasEmptyBase : Empty {};
1380 struct HoldsEmptyBase { Empty e; };
1381 struct HasRepeatedEmptyBase : Empty, HasEmptyBase {}; // expected-warning {{inaccessible}}
1382 struct HasEmptyBaseAsMember : Empty { Empty e; };
1383 struct HasEmptyBaseAsSubobjectOfMember1 : Empty { HoldsEmptyBase e; };
1384 struct HasEmptyBaseAsSubobjectOfMember2 : Empty { HasEmptyBase e; };
1385 struct HasEmptyBaseAsSubobjectOfMember3 : Empty { HoldsEmptyBase e[2]; };
1386 struct HasEmptyIndirectBaseAsMember : HasEmptyBase { Empty e; };
1387 struct HasEmptyIndirectBaseAsSecondMember : HasEmptyBase { int n; Empty e; };
1388 struct HasEmptyIndirectBaseAfterBitfield : HasEmptyBase { int : 4; Empty e; };
1390 int t60[T(__is_standard_layout(Empty))];
1391 int t61[T(__is_standard_layout(HasEmptyBase))];
1392 int t62[F(__is_standard_layout(HasRepeatedEmptyBase))];
1393 int t63[F(__is_standard_layout(HasEmptyBaseAsMember))];
1394 int t64[F(__is_standard_layout(HasEmptyBaseAsSubobjectOfMember1))];
1395 int t65[T(__is_standard_layout(HasEmptyBaseAsSubobjectOfMember2))]; // FIXME: standard bug?
1396 int t66[F(__is_standard_layout(HasEmptyBaseAsSubobjectOfMember3))];
1397 int t67[F(__is_standard_layout(HasEmptyIndirectBaseAsMember))];
1398 int t68[T(__is_standard_layout(HasEmptyIndirectBaseAsSecondMember))];
1399 int t69[F(__is_standard_layout(HasEmptyIndirectBaseAfterBitfield))]; // FIXME: standard bug?
1401 struct StructWithEmptyFields {
1402 int n;
1403 HoldsEmptyBase e[3];
1405 union UnionWithEmptyFields {
1406 int n;
1407 HoldsEmptyBase e[3];
1409 struct HasEmptyIndirectBaseAsSecondStructMember : HasEmptyBase {
1410 StructWithEmptyFields u;
1412 struct HasEmptyIndirectBaseAsSecondUnionMember : HasEmptyBase {
1413 UnionWithEmptyFields u;
1416 int t70[T(__is_standard_layout(HasEmptyIndirectBaseAsSecondStructMember))];
1417 int t71[F(__is_standard_layout(HasEmptyIndirectBaseAsSecondUnionMember))];
1420 void is_signed()
1422 //int t01[T(__is_signed(char))];
1423 int t02[T(__is_signed(int))];
1424 int t03[T(__is_signed(long))];
1425 int t04[T(__is_signed(short))];
1426 int t05[T(__is_signed(signed char))];
1427 int t06[T(__is_signed(wchar_t))];
1428 int t07[T(__is_signed(float))];
1429 int t08[T(__is_signed(double))];
1430 int t09[T(__is_signed(long double))];
1432 int t13[F(__is_signed(bool))];
1433 int t14[F(__is_signed(cvoid))];
1434 int t15[F(__is_signed(unsigned char))];
1435 int t16[F(__is_signed(unsigned int))];
1436 int t17[F(__is_signed(unsigned long long))];
1437 int t18[F(__is_signed(unsigned long))];
1438 int t19[F(__is_signed(unsigned short))];
1439 int t20[F(__is_signed(void))];
1440 int t21[F(__is_signed(ClassType))];
1441 int t22[F(__is_signed(Derives))];
1442 int t23[F(__is_signed(Enum))];
1443 int t24[F(__is_signed(SignedEnum))];
1444 int t25[F(__is_signed(IntArNB))];
1445 int t26[F(__is_signed(Union))];
1446 int t27[F(__is_signed(UnionAr))];
1447 int t28[F(__is_signed(UnsignedEnum))];
1450 void is_unsigned()
1452 int t01[T(__is_unsigned(bool))];
1453 int t02[T(__is_unsigned(unsigned char))];
1454 int t03[T(__is_unsigned(unsigned short))];
1455 int t04[T(__is_unsigned(unsigned int))];
1456 int t05[T(__is_unsigned(unsigned long))];
1457 int t06[T(__is_unsigned(unsigned long long))];
1459 int t10[F(__is_unsigned(void))];
1460 int t11[F(__is_unsigned(cvoid))];
1461 int t12[F(__is_unsigned(float))];
1462 int t13[F(__is_unsigned(double))];
1463 int t14[F(__is_unsigned(long double))];
1464 int t16[F(__is_unsigned(char))];
1465 int t17[F(__is_unsigned(signed char))];
1466 int t18[F(__is_unsigned(wchar_t))];
1467 int t19[F(__is_unsigned(short))];
1468 int t20[F(__is_unsigned(int))];
1469 int t21[F(__is_unsigned(long))];
1470 int t22[F(__is_unsigned(Union))];
1471 int t23[F(__is_unsigned(UnionAr))];
1472 int t24[F(__is_unsigned(Derives))];
1473 int t25[F(__is_unsigned(ClassType))];
1474 int t26[F(__is_unsigned(IntArNB))];
1475 int t27[F(__is_unsigned(Enum))];
1476 int t28[F(__is_unsigned(UnsignedEnum))];
1477 int t29[F(__is_unsigned(SignedEnum))];
1480 typedef Int& IntRef;
1481 typedef const IntAr ConstIntAr;
1482 typedef ConstIntAr ConstIntArAr[4];
1484 struct HasCopy {
1485 HasCopy(HasCopy& cp);
1488 struct HasMove {
1489 HasMove(HasMove&& cp);
1492 struct HasTemplateCons {
1493 HasVirt Annoying;
1495 template <typename T>
1496 HasTemplateCons(const T&);
1499 void has_trivial_default_constructor() {
1500 { int arr[T(__has_trivial_constructor(Int))]; }
1501 { int arr[T(__has_trivial_constructor(IntAr))]; }
1502 { int arr[T(__has_trivial_constructor(Union))]; }
1503 { int arr[T(__has_trivial_constructor(UnionAr))]; }
1504 { int arr[T(__has_trivial_constructor(POD))]; }
1505 { int arr[T(__has_trivial_constructor(Derives))]; }
1506 { int arr[T(__has_trivial_constructor(DerivesAr))]; }
1507 { int arr[T(__has_trivial_constructor(ConstIntAr))]; }
1508 { int arr[T(__has_trivial_constructor(ConstIntArAr))]; }
1509 { int arr[T(__has_trivial_constructor(HasDest))]; }
1510 { int arr[T(__has_trivial_constructor(HasPriv))]; }
1511 { int arr[T(__has_trivial_constructor(HasCopyAssign))]; }
1512 { int arr[T(__has_trivial_constructor(HasMoveAssign))]; }
1513 { int arr[T(__has_trivial_constructor(const Int))]; }
1514 { int arr[T(__has_trivial_constructor(AllDefaulted))]; }
1515 { int arr[T(__has_trivial_constructor(AllDeleted))]; }
1516 { int arr[T(__has_trivial_constructor(ACompleteType[]))]; }
1518 { int arr[F(__has_trivial_constructor(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1519 { int arr[F(__has_trivial_constructor(HasCons))]; }
1520 { int arr[F(__has_trivial_constructor(HasRef))]; }
1521 { int arr[F(__has_trivial_constructor(HasCopy))]; }
1522 { int arr[F(__has_trivial_constructor(IntRef))]; }
1523 { int arr[F(__has_trivial_constructor(VirtAr))]; }
1524 { int arr[F(__has_trivial_constructor(void))]; }
1525 { int arr[F(__has_trivial_constructor(cvoid))]; }
1526 { int arr[F(__has_trivial_constructor(HasTemplateCons))]; }
1527 { int arr[F(__has_trivial_constructor(AllPrivate))]; }
1528 { int arr[F(__has_trivial_constructor(ExtDefaulted))]; }
1531 void has_trivial_move_constructor() {
1532 // n3376 12.8 [class.copy]/12
1533 // A copy/move constructor for class X is trivial if it is not
1534 // user-provided, its declared parameter type is the same as
1535 // if it had been implicitly declared, and if
1536 // - class X has no virtual functions (10.3) and no virtual
1537 // base classes (10.1), and
1538 // - the constructor selected to copy/move each direct base
1539 // class subobject is trivial, and
1540 // - for each non-static data member of X that is of class
1541 // type (or array thereof), the constructor selected
1542 // to copy/move that member is trivial;
1543 // otherwise the copy/move constructor is non-trivial.
1544 { int arr[T(__has_trivial_move_constructor(POD))]; }
1545 { int arr[T(__has_trivial_move_constructor(Union))]; }
1546 { int arr[T(__has_trivial_move_constructor(HasCons))]; }
1547 { int arr[T(__has_trivial_move_constructor(HasStaticMemberMoveCtor))]; }
1548 { int arr[T(__has_trivial_move_constructor(AllDeleted))]; }
1549 { int arr[T(__has_trivial_move_constructor(ACompleteType[]))]; }
1551 { int arr[F(__has_trivial_move_constructor(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1552 { int arr[F(__has_trivial_move_constructor(HasVirt))]; }
1553 { int arr[F(__has_trivial_move_constructor(DerivesVirt))]; }
1554 { int arr[F(__has_trivial_move_constructor(HasMoveCtor))]; }
1555 { int arr[F(__has_trivial_move_constructor(DerivesHasMoveCtor))]; }
1556 { int arr[F(__has_trivial_move_constructor(HasMemberMoveCtor))]; }
1559 void has_trivial_copy_constructor() {
1560 { int arr[T(__has_trivial_copy(Int))]; }
1561 { int arr[T(__has_trivial_copy(IntAr))]; }
1562 { int arr[T(__has_trivial_copy(Union))]; }
1563 { int arr[T(__has_trivial_copy(UnionAr))]; }
1564 { int arr[T(__has_trivial_copy(POD))]; }
1565 { int arr[T(__has_trivial_copy(Derives))]; }
1566 { int arr[T(__has_trivial_copy(ConstIntAr))]; }
1567 { int arr[T(__has_trivial_copy(ConstIntArAr))]; }
1568 { int arr[T(__has_trivial_copy(HasDest))]; }
1569 { int arr[T(__has_trivial_copy(HasPriv))]; }
1570 { int arr[T(__has_trivial_copy(HasCons))]; }
1571 { int arr[T(__has_trivial_copy(HasRef))]; }
1572 { int arr[T(__has_trivial_copy(HasMove))]; }
1573 { int arr[T(__has_trivial_copy(IntRef))]; }
1574 { int arr[T(__has_trivial_copy(HasCopyAssign))]; }
1575 { int arr[T(__has_trivial_copy(HasMoveAssign))]; }
1576 { int arr[T(__has_trivial_copy(const Int))]; }
1577 { int arr[T(__has_trivial_copy(AllDefaulted))]; }
1578 { int arr[T(__has_trivial_copy(AllDeleted))]; }
1579 { int arr[T(__has_trivial_copy(DerivesAr))]; }
1580 { int arr[T(__has_trivial_copy(DerivesHasRef))]; }
1581 { int arr[T(__has_trivial_copy(ACompleteType[]))]; }
1583 { int arr[F(__has_trivial_copy(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1584 { int arr[F(__has_trivial_copy(HasCopy))]; }
1585 { int arr[F(__has_trivial_copy(HasTemplateCons))]; }
1586 { int arr[F(__has_trivial_copy(VirtAr))]; }
1587 { int arr[F(__has_trivial_copy(void))]; }
1588 { int arr[F(__has_trivial_copy(cvoid))]; }
1589 { int arr[F(__has_trivial_copy(AllPrivate))]; }
1590 { int arr[F(__has_trivial_copy(ExtDefaulted))]; }
1593 void has_trivial_copy_assignment() {
1594 { int arr[T(__has_trivial_assign(Int))]; }
1595 { int arr[T(__has_trivial_assign(IntAr))]; }
1596 { int arr[T(__has_trivial_assign(Union))]; }
1597 { int arr[T(__has_trivial_assign(UnionAr))]; }
1598 { int arr[T(__has_trivial_assign(POD))]; }
1599 { int arr[T(__has_trivial_assign(Derives))]; }
1600 { int arr[T(__has_trivial_assign(HasDest))]; }
1601 { int arr[T(__has_trivial_assign(HasPriv))]; }
1602 { int arr[T(__has_trivial_assign(HasCons))]; }
1603 { int arr[T(__has_trivial_assign(HasRef))]; }
1604 { int arr[T(__has_trivial_assign(HasCopy))]; }
1605 { int arr[T(__has_trivial_assign(HasMove))]; }
1606 { int arr[T(__has_trivial_assign(HasMoveAssign))]; }
1607 { int arr[T(__has_trivial_assign(AllDefaulted))]; }
1608 { int arr[T(__has_trivial_assign(AllDeleted))]; }
1609 { int arr[T(__has_trivial_assign(DerivesAr))]; }
1610 { int arr[T(__has_trivial_assign(DerivesHasRef))]; }
1611 { int arr[T(__has_trivial_assign(ACompleteType[]))]; }
1613 { int arr[F(__has_trivial_assign(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1614 { int arr[F(__has_trivial_assign(IntRef))]; }
1615 { int arr[F(__has_trivial_assign(HasCopyAssign))]; }
1616 { int arr[F(__has_trivial_assign(const Int))]; }
1617 { int arr[F(__has_trivial_assign(ConstIntAr))]; }
1618 { int arr[F(__has_trivial_assign(ConstIntArAr))]; }
1619 { int arr[F(__has_trivial_assign(VirtAr))]; }
1620 { int arr[F(__has_trivial_assign(void))]; }
1621 { int arr[F(__has_trivial_assign(cvoid))]; }
1622 { int arr[F(__has_trivial_assign(AllPrivate))]; }
1623 { int arr[F(__has_trivial_assign(ExtDefaulted))]; }
1626 void has_trivial_destructor() {
1627 { int arr[T(__has_trivial_destructor(Int))]; }
1628 { int arr[T(__has_trivial_destructor(IntAr))]; }
1629 { int arr[T(__has_trivial_destructor(Union))]; }
1630 { int arr[T(__has_trivial_destructor(UnionAr))]; }
1631 { int arr[T(__has_trivial_destructor(POD))]; }
1632 { int arr[T(__has_trivial_destructor(Derives))]; }
1633 { int arr[T(__has_trivial_destructor(ConstIntAr))]; }
1634 { int arr[T(__has_trivial_destructor(ConstIntArAr))]; }
1635 { int arr[T(__has_trivial_destructor(HasPriv))]; }
1636 { int arr[T(__has_trivial_destructor(HasCons))]; }
1637 { int arr[T(__has_trivial_destructor(HasRef))]; }
1638 { int arr[T(__has_trivial_destructor(HasCopy))]; }
1639 { int arr[T(__has_trivial_destructor(HasMove))]; }
1640 { int arr[T(__has_trivial_destructor(IntRef))]; }
1641 { int arr[T(__has_trivial_destructor(HasCopyAssign))]; }
1642 { int arr[T(__has_trivial_destructor(HasMoveAssign))]; }
1643 { int arr[T(__has_trivial_destructor(const Int))]; }
1644 { int arr[T(__has_trivial_destructor(DerivesAr))]; }
1645 { int arr[T(__has_trivial_destructor(VirtAr))]; }
1646 { int arr[T(__has_trivial_destructor(AllDefaulted))]; }
1647 { int arr[T(__has_trivial_destructor(AllDeleted))]; }
1648 { int arr[T(__has_trivial_destructor(DerivesHasRef))]; }
1649 { int arr[T(__has_trivial_destructor(ACompleteType[]))]; }
1651 { int arr[F(__has_trivial_destructor(HasDest))]; }
1652 { int arr[F(__has_trivial_destructor(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1653 { int arr[F(__has_trivial_destructor(void))]; }
1654 { int arr[F(__has_trivial_destructor(cvoid))]; }
1655 { int arr[F(__has_trivial_destructor(AllPrivate))]; }
1656 { int arr[F(__has_trivial_destructor(ExtDefaulted))]; }
1659 struct A { ~A() {} };
1660 template<typename> struct B : A { };
1662 void f() {
1663 { int arr[F(__has_trivial_destructor(A))]; }
1664 { int arr[F(__has_trivial_destructor(B<int>))]; }
1667 class PR11110 {
1668 template <int> int operator=( int );
1669 int operator=(PR11110);
1672 class UsingAssign;
1674 class UsingAssignBase {
1675 protected:
1676 UsingAssign &operator=(const UsingAssign&) throw();
1679 class UsingAssign : public UsingAssignBase {
1680 public:
1681 using UsingAssignBase::operator=;
1684 void has_nothrow_assign() {
1685 { int arr[T(__has_nothrow_assign(Int))]; }
1686 { int arr[T(__has_nothrow_assign(IntAr))]; }
1687 { int arr[T(__has_nothrow_assign(Union))]; }
1688 { int arr[T(__has_nothrow_assign(UnionAr))]; }
1689 { int arr[T(__has_nothrow_assign(POD))]; }
1690 { int arr[T(__has_nothrow_assign(Derives))]; }
1691 { int arr[T(__has_nothrow_assign(HasDest))]; }
1692 { int arr[T(__has_nothrow_assign(HasPriv))]; }
1693 { int arr[T(__has_nothrow_assign(HasCons))]; }
1694 { int arr[T(__has_nothrow_assign(HasRef))]; }
1695 { int arr[T(__has_nothrow_assign(HasCopy))]; }
1696 { int arr[T(__has_nothrow_assign(HasMove))]; }
1697 { int arr[T(__has_nothrow_assign(HasMoveAssign))]; }
1698 { int arr[T(__has_nothrow_assign(HasNoThrowCopyAssign))]; }
1699 { int arr[T(__has_nothrow_assign(HasMultipleNoThrowCopyAssign))]; }
1700 { int arr[T(__has_nothrow_assign(HasVirtDest))]; }
1701 { int arr[T(__has_nothrow_assign(AllPrivate))]; }
1702 { int arr[T(__has_nothrow_assign(UsingAssign))]; }
1703 { int arr[T(__has_nothrow_assign(DerivesAr))]; }
1704 { int arr[T(__has_nothrow_assign(ACompleteType[]))]; }
1706 { int arr[F(__has_nothrow_assign(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1707 { int arr[F(__has_nothrow_assign(IntRef))]; }
1708 { int arr[F(__has_nothrow_assign(HasCopyAssign))]; }
1709 { int arr[F(__has_nothrow_assign(HasMultipleCopyAssign))]; }
1710 { int arr[F(__has_nothrow_assign(const Int))]; }
1711 { int arr[F(__has_nothrow_assign(ConstIntAr))]; }
1712 { int arr[F(__has_nothrow_assign(ConstIntArAr))]; }
1713 { int arr[F(__has_nothrow_assign(VirtAr))]; }
1714 { int arr[F(__has_nothrow_assign(void))]; }
1715 { int arr[F(__has_nothrow_assign(cvoid))]; }
1716 { int arr[F(__has_nothrow_assign(PR11110))]; }
1719 void has_nothrow_move_assign() {
1720 { int arr[T(__has_nothrow_move_assign(Int))]; }
1721 { int arr[T(__has_nothrow_move_assign(Enum))]; }
1722 { int arr[T(__has_nothrow_move_assign(Int*))]; }
1723 { int arr[T(__has_nothrow_move_assign(Enum POD::*))]; }
1724 { int arr[T(__has_nothrow_move_assign(POD))]; }
1725 { int arr[T(__has_nothrow_move_assign(HasPriv))]; }
1726 { int arr[T(__has_nothrow_move_assign(HasNoThrowMoveAssign))]; }
1727 { int arr[T(__has_nothrow_move_assign(HasNoExceptNoThrowMoveAssign))]; }
1728 { int arr[T(__has_nothrow_move_assign(HasMemberNoThrowMoveAssign))]; }
1729 { int arr[T(__has_nothrow_move_assign(HasMemberNoExceptNoThrowMoveAssign))]; }
1730 { int arr[T(__has_nothrow_move_assign(AllDeleted))]; }
1731 { int arr[T(__has_nothrow_move_assign(ACompleteType[]))]; }
1733 { int arr[F(__has_nothrow_move_assign(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1734 { int arr[F(__has_nothrow_move_assign(HasThrowMoveAssign))]; }
1735 { int arr[F(__has_nothrow_move_assign(HasNoExceptFalseMoveAssign))]; }
1736 { int arr[F(__has_nothrow_move_assign(HasMemberThrowMoveAssign))]; }
1737 { int arr[F(__has_nothrow_move_assign(HasMemberNoExceptFalseMoveAssign))]; }
1738 { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyCtor))]; }
1739 { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyAssign))]; }
1740 { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToDtor))]; }
1743 { int arr[T(__is_nothrow_assignable(HasNoThrowMoveAssign, HasNoThrowMoveAssign))]; }
1744 { int arr[F(__is_nothrow_assignable(HasThrowMoveAssign, HasThrowMoveAssign))]; }
1746 { int arr[T(__is_assignable(HasNoThrowMoveAssign, HasNoThrowMoveAssign))]; }
1747 { int arr[T(__is_assignable(HasThrowMoveAssign, HasThrowMoveAssign))]; }
1750 void has_trivial_move_assign() {
1751 // n3376 12.8 [class.copy]/25
1752 // A copy/move assignment operator for class X is trivial if it
1753 // is not user-provided, its declared parameter type is the same
1754 // as if it had been implicitly declared, and if:
1755 // - class X has no virtual functions (10.3) and no virtual base
1756 // classes (10.1), and
1757 // - the assignment operator selected to copy/move each direct
1758 // base class subobject is trivial, and
1759 // - for each non-static data member of X that is of class type
1760 // (or array thereof), the assignment operator
1761 // selected to copy/move that member is trivial;
1762 { int arr[T(__has_trivial_move_assign(Int))]; }
1763 { int arr[T(__has_trivial_move_assign(HasStaticMemberMoveAssign))]; }
1764 { int arr[T(__has_trivial_move_assign(AllDeleted))]; }
1765 { int arr[T(__has_trivial_move_assign(ACompleteType[]))]; }
1767 { int arr[F(__has_trivial_move_assign(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1768 { int arr[F(__has_trivial_move_assign(HasVirt))]; }
1769 { int arr[F(__has_trivial_move_assign(DerivesVirt))]; }
1770 { int arr[F(__has_trivial_move_assign(HasMoveAssign))]; }
1771 { int arr[F(__has_trivial_move_assign(DerivesHasMoveAssign))]; }
1772 { int arr[F(__has_trivial_move_assign(HasMemberMoveAssign))]; }
1773 { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyCtor))]; }
1774 { int arr[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyAssign))]; }
1777 void has_nothrow_copy() {
1778 { int arr[T(__has_nothrow_copy(Int))]; }
1779 { int arr[T(__has_nothrow_copy(IntAr))]; }
1780 { int arr[T(__has_nothrow_copy(Union))]; }
1781 { int arr[T(__has_nothrow_copy(UnionAr))]; }
1782 { int arr[T(__has_nothrow_copy(POD))]; }
1783 { int arr[T(__has_nothrow_copy(const Int))]; }
1784 { int arr[T(__has_nothrow_copy(ConstIntAr))]; }
1785 { int arr[T(__has_nothrow_copy(ConstIntArAr))]; }
1786 { int arr[T(__has_nothrow_copy(Derives))]; }
1787 { int arr[T(__has_nothrow_copy(IntRef))]; }
1788 { int arr[T(__has_nothrow_copy(HasDest))]; }
1789 { int arr[T(__has_nothrow_copy(HasPriv))]; }
1790 { int arr[T(__has_nothrow_copy(HasCons))]; }
1791 { int arr[T(__has_nothrow_copy(HasRef))]; }
1792 { int arr[T(__has_nothrow_copy(HasMove))]; }
1793 { int arr[T(__has_nothrow_copy(HasCopyAssign))]; }
1794 { int arr[T(__has_nothrow_copy(HasMoveAssign))]; }
1795 { int arr[T(__has_nothrow_copy(HasNoThrowCopy))]; }
1796 { int arr[T(__has_nothrow_copy(HasMultipleNoThrowCopy))]; }
1797 { int arr[T(__has_nothrow_copy(HasVirtDest))]; }
1798 { int arr[T(__has_nothrow_copy(HasTemplateCons))]; }
1799 { int arr[T(__has_nothrow_copy(AllPrivate))]; }
1800 { int arr[T(__has_nothrow_copy(DerivesAr))]; }
1801 { int arr[T(__has_nothrow_copy(ACompleteType[]))]; }
1803 { int arr[F(__has_nothrow_copy(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1804 { int arr[F(__has_nothrow_copy(HasCopy))]; }
1805 { int arr[F(__has_nothrow_copy(HasMultipleCopy))]; }
1806 { int arr[F(__has_nothrow_copy(VirtAr))]; }
1807 { int arr[F(__has_nothrow_copy(void))]; }
1808 { int arr[F(__has_nothrow_copy(cvoid))]; }
1811 void has_nothrow_constructor() {
1812 { int arr[T(__has_nothrow_constructor(Int))]; }
1813 { int arr[T(__has_nothrow_constructor(IntAr))]; }
1814 { int arr[T(__has_nothrow_constructor(Union))]; }
1815 { int arr[T(__has_nothrow_constructor(UnionAr))]; }
1816 { int arr[T(__has_nothrow_constructor(POD))]; }
1817 { int arr[T(__has_nothrow_constructor(Derives))]; }
1818 { int arr[T(__has_nothrow_constructor(DerivesAr))]; }
1819 { int arr[T(__has_nothrow_constructor(ConstIntAr))]; }
1820 { int arr[T(__has_nothrow_constructor(ConstIntArAr))]; }
1821 { int arr[T(__has_nothrow_constructor(HasDest))]; }
1822 { int arr[T(__has_nothrow_constructor(HasPriv))]; }
1823 { int arr[T(__has_nothrow_constructor(HasCopyAssign))]; }
1824 { int arr[T(__has_nothrow_constructor(const Int))]; }
1825 { int arr[T(__has_nothrow_constructor(HasNoThrowConstructor))]; }
1826 { int arr[T(__has_nothrow_constructor(HasVirtDest))]; }
1827 // { int arr[T(__has_nothrow_constructor(VirtAr))]; } // not implemented
1828 { int arr[T(__has_nothrow_constructor(AllPrivate))]; }
1829 { int arr[T(__has_nothrow_constructor(ACompleteType[]))]; }
1831 { int arr[F(__has_nothrow_constructor(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1832 { int arr[F(__has_nothrow_constructor(HasCons))]; }
1833 { int arr[F(__has_nothrow_constructor(HasRef))]; }
1834 { int arr[F(__has_nothrow_constructor(HasCopy))]; }
1835 { int arr[F(__has_nothrow_constructor(HasMove))]; }
1836 { int arr[F(__has_nothrow_constructor(HasNoThrowConstructorWithArgs))]; }
1837 { int arr[F(__has_nothrow_constructor(IntRef))]; }
1838 { int arr[F(__has_nothrow_constructor(void))]; }
1839 { int arr[F(__has_nothrow_constructor(cvoid))]; }
1840 { int arr[F(__has_nothrow_constructor(HasTemplateCons))]; }
1842 { int arr[F(__has_nothrow_constructor(HasMultipleDefaultConstructor1))]; }
1843 { int arr[F(__has_nothrow_constructor(HasMultipleDefaultConstructor2))]; }
1846 void has_virtual_destructor() {
1847 { int arr[F(__has_virtual_destructor(Int))]; }
1848 { int arr[F(__has_virtual_destructor(IntAr))]; }
1849 { int arr[F(__has_virtual_destructor(Union))]; }
1850 { int arr[F(__has_virtual_destructor(UnionAr))]; }
1851 { int arr[F(__has_virtual_destructor(POD))]; }
1852 { int arr[F(__has_virtual_destructor(Derives))]; }
1853 { int arr[F(__has_virtual_destructor(DerivesAr))]; }
1854 { int arr[F(__has_virtual_destructor(const Int))]; }
1855 { int arr[F(__has_virtual_destructor(ConstIntAr))]; }
1856 { int arr[F(__has_virtual_destructor(ConstIntArAr))]; }
1857 { int arr[F(__has_virtual_destructor(HasDest))]; }
1858 { int arr[F(__has_virtual_destructor(HasPriv))]; }
1859 { int arr[F(__has_virtual_destructor(HasCons))]; }
1860 { int arr[F(__has_virtual_destructor(HasRef))]; }
1861 { int arr[F(__has_virtual_destructor(HasCopy))]; }
1862 { int arr[F(__has_virtual_destructor(HasMove))]; }
1863 { int arr[F(__has_virtual_destructor(HasCopyAssign))]; }
1864 { int arr[F(__has_virtual_destructor(HasMoveAssign))]; }
1865 { int arr[F(__has_virtual_destructor(IntRef))]; }
1866 { int arr[F(__has_virtual_destructor(VirtAr))]; }
1867 { int arr[F(__has_virtual_destructor(ACompleteType[]))]; }
1869 { int arr[F(__has_virtual_destructor(AnIncompleteType[]))]; } // expected-error {{incomplete type}}
1870 { int arr[T(__has_virtual_destructor(HasVirtDest))]; }
1871 { int arr[T(__has_virtual_destructor(DerivedVirtDest))]; }
1872 { int arr[F(__has_virtual_destructor(VirtDestAr))]; }
1873 { int arr[F(__has_virtual_destructor(void))]; }
1874 { int arr[F(__has_virtual_destructor(cvoid))]; }
1875 { int arr[F(__has_virtual_destructor(AllPrivate))]; }
1879 class Base {};
1880 class Derived : Base {};
1881 class Derived2a : Derived {};
1882 class Derived2b : Derived {};
1883 class Derived3 : virtual Derived2a, virtual Derived2b {};
1884 template<typename T> struct BaseA { T a; };
1885 template<typename T> struct DerivedB : BaseA<T> { };
1886 template<typename T> struct CrazyDerived : T { };
1889 class class_forward; // expected-note 2 {{forward declaration of 'class_forward'}}
1891 template <typename Base, typename Derived>
1892 void isBaseOfT() {
1893 int t[T(__is_base_of(Base, Derived))];
1895 template <typename Base, typename Derived>
1896 void isBaseOfF() {
1897 int t[F(__is_base_of(Base, Derived))];
1900 template <class T> class DerivedTemp : Base {};
1901 template <class T> class NonderivedTemp {};
1902 template <class T> class UndefinedTemp; // expected-note {{declared here}}
1904 void is_base_of() {
1905 { int arr[T(__is_base_of(Base, Derived))]; }
1906 { int arr[T(__is_base_of(const Base, Derived))]; }
1907 { int arr[F(__is_base_of(Derived, Base))]; }
1908 { int arr[F(__is_base_of(Derived, int))]; }
1909 { int arr[T(__is_base_of(Base, Base))]; }
1910 { int arr[T(__is_base_of(Base, Derived3))]; }
1911 { int arr[T(__is_base_of(Derived, Derived3))]; }
1912 { int arr[T(__is_base_of(Derived2b, Derived3))]; }
1913 { int arr[T(__is_base_of(Derived2a, Derived3))]; }
1914 { int arr[T(__is_base_of(BaseA<int>, DerivedB<int>))]; }
1915 { int arr[F(__is_base_of(DerivedB<int>, BaseA<int>))]; }
1916 { int arr[T(__is_base_of(Base, CrazyDerived<Base>))]; }
1917 { int arr[F(__is_base_of(Union, Union))]; }
1918 { int arr[T(__is_base_of(Empty, Empty))]; }
1919 { int arr[T(__is_base_of(class_forward, class_forward))]; }
1920 { int arr[F(__is_base_of(Empty, class_forward))]; } // expected-error {{incomplete type 'class_forward' used in type trait expression}}
1921 { int arr[F(__is_base_of(Base&, Derived&))]; }
1922 int t18[F(__is_base_of(Base[10], Derived[10]))];
1923 { int arr[F(__is_base_of(int, int))]; }
1924 { int arr[F(__is_base_of(long, int))]; }
1925 { int arr[T(__is_base_of(Base, DerivedTemp<int>))]; }
1926 { int arr[F(__is_base_of(Base, NonderivedTemp<int>))]; }
1927 { int arr[F(__is_base_of(Base, UndefinedTemp<int>))]; } // expected-error {{implicit instantiation of undefined template 'UndefinedTemp<int>'}}
1929 { int arr[F(__is_base_of(IncompleteUnion, IncompleteUnion))]; }
1930 { int arr[F(__is_base_of(Union, IncompleteUnion))]; }
1931 { int arr[F(__is_base_of(IncompleteUnion, Union))]; }
1932 { int arr[F(__is_base_of(IncompleteStruct, IncompleteUnion))]; }
1933 { int arr[F(__is_base_of(IncompleteUnion, IncompleteStruct))]; }
1934 { int arr[F(__is_base_of(Empty, IncompleteUnion))]; }
1935 { int arr[F(__is_base_of(IncompleteUnion, Empty))]; }
1936 { int arr[F(__is_base_of(int, IncompleteUnion))]; }
1937 { int arr[F(__is_base_of(IncompleteUnion, int))]; }
1938 { int arr[F(__is_base_of(Empty, Union))]; }
1939 { int arr[F(__is_base_of(Union, Empty))]; }
1940 { int arr[F(__is_base_of(int, Empty))]; }
1941 { int arr[F(__is_base_of(Union, int))]; }
1943 isBaseOfT<Base, Derived>();
1944 isBaseOfF<Derived, Base>();
1946 isBaseOfT<Base, CrazyDerived<Base> >();
1947 isBaseOfF<CrazyDerived<Base>, Base>();
1949 isBaseOfT<BaseA<int>, DerivedB<int> >();
1950 isBaseOfF<DerivedB<int>, BaseA<int> >();
1953 template<class T, class U>
1954 class TemplateClass {};
1956 template<class T>
1957 using TemplateAlias = TemplateClass<T, int>;
1959 typedef class Base BaseTypedef;
1961 void is_same()
1963 int t01[T(__is_same(Base, Base))];
1964 int t02[T(__is_same(Base, BaseTypedef))];
1965 int t03[T(__is_same(TemplateClass<int, int>, TemplateAlias<int>))];
1967 int t10[F(__is_same(Base, const Base))];
1968 int t11[F(__is_same(Base, Base&))];
1969 int t12[F(__is_same(Base, Derived))];
1971 // __is_same_as is a GCC compatibility synonym for __is_same.
1972 int t20[T(__is_same_as(int, int))];
1973 int t21[F(__is_same_as(int, float))];
1976 struct IntWrapper
1978 int value;
1979 IntWrapper(int _value) : value(_value) {}
1980 operator int() const {
1981 return value;
1985 struct FloatWrapper
1987 float value;
1988 FloatWrapper(float _value) : value(_value) {}
1989 FloatWrapper(const IntWrapper& obj)
1990 : value(static_cast<float>(obj.value)) {}
1991 operator float() const {
1992 return value;
1994 operator IntWrapper() const {
1995 return IntWrapper(static_cast<int>(value));
1999 void is_convertible()
2001 int t01[T(__is_convertible(IntWrapper, IntWrapper))];
2002 int t02[T(__is_convertible(IntWrapper, const IntWrapper))];
2003 int t03[T(__is_convertible(IntWrapper, int))];
2004 int t04[T(__is_convertible(int, IntWrapper))];
2005 int t05[T(__is_convertible(IntWrapper, FloatWrapper))];
2006 int t06[T(__is_convertible(FloatWrapper, IntWrapper))];
2007 int t07[T(__is_convertible(FloatWrapper, float))];
2008 int t08[T(__is_convertible(float, FloatWrapper))];
2011 struct FromInt { FromInt(int); };
2012 struct ToInt { operator int(); };
2013 typedef void Function();
2015 void is_convertible_to();
2016 class PrivateCopy {
2017 PrivateCopy(const PrivateCopy&);
2018 friend void is_convertible_to();
2021 template<typename T>
2022 struct X0 {
2023 template<typename U> X0(const X0<U>&);
2026 struct Abstract { virtual void f() = 0; };
2028 void is_convertible_to() {
2029 { int arr[T(__is_convertible_to(Int, Int))]; }
2030 { int arr[F(__is_convertible_to(Int, IntAr))]; }
2031 { int arr[F(__is_convertible_to(IntAr, IntAr))]; }
2032 { int arr[T(__is_convertible_to(void, void))]; }
2033 { int arr[T(__is_convertible_to(cvoid, void))]; }
2034 { int arr[T(__is_convertible_to(void, cvoid))]; }
2035 { int arr[T(__is_convertible_to(cvoid, cvoid))]; }
2036 { int arr[T(__is_convertible_to(int, FromInt))]; }
2037 { int arr[T(__is_convertible_to(long, FromInt))]; }
2038 { int arr[T(__is_convertible_to(double, FromInt))]; }
2039 { int arr[T(__is_convertible_to(const int, FromInt))]; }
2040 { int arr[T(__is_convertible_to(const int&, FromInt))]; }
2041 { int arr[T(__is_convertible_to(ToInt, int))]; }
2042 { int arr[T(__is_convertible_to(ToInt, const int&))]; }
2043 { int arr[T(__is_convertible_to(ToInt, long))]; }
2044 { int arr[F(__is_convertible_to(ToInt, int&))]; }
2045 { int arr[F(__is_convertible_to(ToInt, FromInt))]; }
2046 { int arr[T(__is_convertible_to(IntAr&, IntAr&))]; }
2047 { int arr[T(__is_convertible_to(IntAr&, const IntAr&))]; }
2048 { int arr[F(__is_convertible_to(const IntAr&, IntAr&))]; }
2049 { int arr[F(__is_convertible_to(Function, Function))]; }
2050 { int arr[F(__is_convertible_to(PrivateCopy, PrivateCopy))]; }
2051 { int arr[T(__is_convertible_to(X0<int>, X0<float>))]; }
2052 { int arr[F(__is_convertible_to(Abstract, Abstract))]; }
2055 namespace is_convertible_to_instantiate {
2056 // Make sure we don't try to instantiate the constructor.
2057 template<int x> class A { A(int) { int a[x]; } };
2058 int x = __is_convertible_to(int, A<-1>);
2061 void is_trivial()
2063 { int arr[T(__is_trivial(int))]; }
2064 { int arr[T(__is_trivial(Enum))]; }
2065 { int arr[T(__is_trivial(POD))]; }
2066 { int arr[T(__is_trivial(Int))]; }
2067 { int arr[T(__is_trivial(IntAr))]; }
2068 { int arr[T(__is_trivial(IntArNB))]; }
2069 { int arr[T(__is_trivial(Statics))]; }
2070 { int arr[T(__is_trivial(Empty))]; }
2071 { int arr[T(__is_trivial(EmptyUnion))]; }
2072 { int arr[T(__is_trivial(Union))]; }
2073 { int arr[T(__is_trivial(Derives))]; }
2074 { int arr[T(__is_trivial(DerivesAr))]; }
2075 { int arr[T(__is_trivial(DerivesArNB))]; }
2076 { int arr[T(__is_trivial(DerivesEmpty))]; }
2077 { int arr[T(__is_trivial(HasFunc))]; }
2078 { int arr[T(__is_trivial(HasOp))]; }
2079 { int arr[T(__is_trivial(HasConv))]; }
2080 { int arr[T(__is_trivial(HasAssign))]; }
2081 { int arr[T(__is_trivial(HasAnonymousUnion))]; }
2082 { int arr[T(__is_trivial(HasPriv))]; }
2083 { int arr[T(__is_trivial(HasProt))]; }
2084 { int arr[T(__is_trivial(DerivesHasPriv))]; }
2085 { int arr[T(__is_trivial(DerivesHasProt))]; }
2086 { int arr[T(__is_trivial(Vector))]; }
2087 { int arr[T(__is_trivial(VectorExt))]; }
2089 { int arr[F(__is_trivial(HasCons))]; }
2090 { int arr[F(__is_trivial(HasCopyAssign))]; }
2091 { int arr[F(__is_trivial(HasMoveAssign))]; }
2092 { int arr[F(__is_trivial(HasDest))]; }
2093 { int arr[F(__is_trivial(HasRef))]; }
2094 { int arr[F(__is_trivial(HasNonPOD))]; }
2095 { int arr[F(__is_trivial(HasVirt))]; }
2096 { int arr[F(__is_trivial(DerivesHasCons))]; }
2097 { int arr[F(__is_trivial(DerivesHasCopyAssign))]; }
2098 { int arr[F(__is_trivial(DerivesHasMoveAssign))]; }
2099 { int arr[F(__is_trivial(DerivesHasDest))]; }
2100 { int arr[F(__is_trivial(DerivesHasRef))]; }
2101 { int arr[F(__is_trivial(DerivesHasVirt))]; }
2102 { int arr[F(__is_trivial(void))]; }
2103 { int arr[F(__is_trivial(cvoid))]; }
2106 template<typename T> struct TriviallyConstructibleTemplate {};
2108 void trivial_checks()
2110 { int arr[T(__is_trivially_copyable(int))]; }
2111 { int arr[T(__is_trivially_copyable(Enum))]; }
2112 { int arr[T(__is_trivially_copyable(POD))]; }
2113 { int arr[T(__is_trivially_copyable(Int))]; }
2114 { int arr[T(__is_trivially_copyable(IntAr))]; }
2115 { int arr[T(__is_trivially_copyable(IntArNB))]; }
2116 { int arr[T(__is_trivially_copyable(Statics))]; }
2117 { int arr[T(__is_trivially_copyable(Empty))]; }
2118 { int arr[T(__is_trivially_copyable(EmptyUnion))]; }
2119 { int arr[T(__is_trivially_copyable(Union))]; }
2120 { int arr[T(__is_trivially_copyable(Derives))]; }
2121 { int arr[T(__is_trivially_copyable(DerivesAr))]; }
2122 { int arr[T(__is_trivially_copyable(DerivesArNB))]; }
2123 { int arr[T(__is_trivially_copyable(DerivesEmpty))]; }
2124 { int arr[T(__is_trivially_copyable(HasFunc))]; }
2125 { int arr[T(__is_trivially_copyable(HasOp))]; }
2126 { int arr[T(__is_trivially_copyable(HasConv))]; }
2127 { int arr[T(__is_trivially_copyable(HasAssign))]; }
2128 { int arr[T(__is_trivially_copyable(HasAnonymousUnion))]; }
2129 { int arr[T(__is_trivially_copyable(HasPriv))]; }
2130 { int arr[T(__is_trivially_copyable(HasProt))]; }
2131 { int arr[T(__is_trivially_copyable(DerivesHasPriv))]; }
2132 { int arr[T(__is_trivially_copyable(DerivesHasProt))]; }
2133 { int arr[T(__is_trivially_copyable(Vector))]; }
2134 { int arr[T(__is_trivially_copyable(VectorExt))]; }
2135 { int arr[T(__is_trivially_copyable(HasCons))]; }
2136 { int arr[T(__is_trivially_copyable(HasRef))]; }
2137 { int arr[T(__is_trivially_copyable(HasNonPOD))]; }
2138 { int arr[T(__is_trivially_copyable(DerivesHasCons))]; }
2139 { int arr[T(__is_trivially_copyable(DerivesHasRef))]; }
2140 { int arr[T(__is_trivially_copyable(NonTrivialDefault))]; }
2141 { int arr[T(__is_trivially_copyable(NonTrivialDefault[]))]; }
2142 { int arr[T(__is_trivially_copyable(NonTrivialDefault[3]))]; }
2144 { int arr[F(__is_trivially_copyable(HasCopyAssign))]; }
2145 { int arr[F(__is_trivially_copyable(HasMoveAssign))]; }
2146 { int arr[F(__is_trivially_copyable(HasDest))]; }
2147 { int arr[F(__is_trivially_copyable(HasVirt))]; }
2148 { int arr[F(__is_trivially_copyable(DerivesHasCopyAssign))]; }
2149 { int arr[F(__is_trivially_copyable(DerivesHasMoveAssign))]; }
2150 { int arr[F(__is_trivially_copyable(DerivesHasDest))]; }
2151 { int arr[F(__is_trivially_copyable(DerivesHasVirt))]; }
2152 { int arr[F(__is_trivially_copyable(void))]; }
2153 { int arr[F(__is_trivially_copyable(cvoid))]; }
2155 { int arr[T((__is_trivially_constructible(int)))]; }
2156 { int arr[T((__is_trivially_constructible(int, int)))]; }
2157 { int arr[T((__is_trivially_constructible(int, float)))]; }
2158 { int arr[T((__is_trivially_constructible(int, int&)))]; }
2159 { int arr[T((__is_trivially_constructible(int, const int&)))]; }
2160 { int arr[T((__is_trivially_constructible(int, int)))]; }
2161 { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign)))]; }
2162 { int arr[T((__is_trivially_constructible(HasCopyAssign, const HasCopyAssign&)))]; }
2163 { int arr[T((__is_trivially_constructible(HasCopyAssign, HasCopyAssign&&)))]; }
2164 { int arr[T((__is_trivially_constructible(HasCopyAssign)))]; }
2165 { int arr[T((__is_trivially_constructible(NonTrivialDefault,
2166 const NonTrivialDefault&)))]; }
2167 { int arr[T((__is_trivially_constructible(NonTrivialDefault,
2168 NonTrivialDefault&&)))]; }
2169 { int arr[T((__is_trivially_constructible(AllDefaulted)))]; }
2170 { int arr[T((__is_trivially_constructible(AllDefaulted,
2171 const AllDefaulted &)))]; }
2172 { int arr[T((__is_trivially_constructible(AllDefaulted,
2173 AllDefaulted &&)))]; }
2175 { int arr[F((__is_trivially_constructible(int, int*)))]; }
2176 { int arr[F((__is_trivially_constructible(NonTrivialDefault)))]; }
2177 { int arr[F((__is_trivially_constructible(ThreeArgCtor, int*, char*, int&)))]; }
2178 { int arr[F((__is_trivially_constructible(AllDeleted)))]; }
2179 { int arr[F((__is_trivially_constructible(AllDeleted,
2180 const AllDeleted &)))]; }
2181 { int arr[F((__is_trivially_constructible(AllDeleted,
2182 AllDeleted &&)))]; }
2183 { int arr[F((__is_trivially_constructible(ExtDefaulted)))]; }
2184 { int arr[F((__is_trivially_constructible(ExtDefaulted,
2185 const ExtDefaulted &)))]; }
2186 { int arr[F((__is_trivially_constructible(ExtDefaulted,
2187 ExtDefaulted &&)))]; }
2189 { int arr[T((__is_trivially_constructible(TriviallyConstructibleTemplate<int>)))]; }
2190 { int arr[F((__is_trivially_constructible(class_forward)))]; } // expected-error {{incomplete type 'class_forward' used in type trait expression}}
2191 { int arr[F((__is_trivially_constructible(class_forward[])))]; }
2192 { int arr[F((__is_trivially_constructible(void)))]; }
2194 { int arr[T((__is_trivially_assignable(int&, int)))]; }
2195 { int arr[T((__is_trivially_assignable(int&, int&)))]; }
2196 { int arr[T((__is_trivially_assignable(int&, int&&)))]; }
2197 { int arr[T((__is_trivially_assignable(int&, const int&)))]; }
2198 { int arr[T((__is_trivially_assignable(POD&, POD)))]; }
2199 { int arr[T((__is_trivially_assignable(POD&, POD&)))]; }
2200 { int arr[T((__is_trivially_assignable(POD&, POD&&)))]; }
2201 { int arr[T((__is_trivially_assignable(POD&, const POD&)))]; }
2202 { int arr[T((__is_trivially_assignable(int*&, int*)))]; }
2203 { int arr[T((__is_trivially_assignable(AllDefaulted,
2204 const AllDefaulted &)))]; }
2205 { int arr[T((__is_trivially_assignable(AllDefaulted,
2206 AllDefaulted &&)))]; }
2208 { int arr[F((__is_trivially_assignable(int*&, float*)))]; }
2209 { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign)))]; }
2210 { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign&)))]; }
2211 { int arr[F((__is_trivially_assignable(HasCopyAssign&, const HasCopyAssign&)))]; }
2212 { int arr[F((__is_trivially_assignable(HasCopyAssign&, HasCopyAssign&&)))]; }
2213 { int arr[F((__is_trivially_assignable(TrivialMoveButNotCopy&,
2214 TrivialMoveButNotCopy&)))]; }
2215 { int arr[F((__is_trivially_assignable(TrivialMoveButNotCopy&,
2216 const TrivialMoveButNotCopy&)))]; }
2217 { int arr[F((__is_trivially_assignable(AllDeleted,
2218 const AllDeleted &)))]; }
2219 { int arr[F((__is_trivially_assignable(AllDeleted,
2220 AllDeleted &&)))]; }
2221 { int arr[F((__is_trivially_assignable(ExtDefaulted,
2222 const ExtDefaulted &)))]; }
2223 { int arr[F((__is_trivially_assignable(ExtDefaulted,
2224 ExtDefaulted &&)))]; }
2226 { int arr[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign&,
2227 HasDefaultTrivialCopyAssign&)))]; }
2228 { int arr[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign&,
2229 const HasDefaultTrivialCopyAssign&)))]; }
2230 { int arr[T((__is_trivially_assignable(TrivialMoveButNotCopy&,
2231 TrivialMoveButNotCopy)))]; }
2232 { int arr[T((__is_trivially_assignable(TrivialMoveButNotCopy&,
2233 TrivialMoveButNotCopy&&)))]; }
2234 { int arr[T((__is_trivially_assignable(int&, int)))]; }
2235 { int arr[T((__is_trivially_assignable(int&, int&)))]; }
2236 { int arr[T((__is_trivially_assignable(int&, int&&)))]; }
2237 { int arr[T((__is_trivially_assignable(int&, const int&)))]; }
2238 { int arr[T((__is_trivially_assignable(POD&, POD)))]; }
2239 { int arr[T((__is_trivially_assignable(POD&, POD&)))]; }
2240 { int arr[T((__is_trivially_assignable(POD&, POD&&)))]; }
2241 { int arr[T((__is_trivially_assignable(POD&, const POD&)))]; }
2242 { int arr[T((__is_trivially_assignable(int*&, int*)))]; }
2243 { int arr[T((__is_trivially_assignable(AllDefaulted,
2244 const AllDefaulted &)))]; }
2245 { int arr[T((__is_trivially_assignable(AllDefaulted,
2246 AllDefaulted &&)))]; }
2248 { int arr[F((__is_assignable(int *&, float *)))]; }
2249 { int arr[T((__is_assignable(HasCopyAssign &, HasCopyAssign)))]; }
2250 { int arr[T((__is_assignable(HasCopyAssign &, HasCopyAssign &)))]; }
2251 { int arr[T((__is_assignable(HasCopyAssign &, const HasCopyAssign &)))]; }
2252 { int arr[T((__is_assignable(HasCopyAssign &, HasCopyAssign &&)))]; }
2253 { int arr[T((__is_assignable(TrivialMoveButNotCopy &,
2254 TrivialMoveButNotCopy &)))]; }
2255 { int arr[T((__is_assignable(TrivialMoveButNotCopy &,
2256 const TrivialMoveButNotCopy &)))]; }
2257 { int arr[F((__is_assignable(AllDeleted,
2258 const AllDeleted &)))]; }
2259 { int arr[F((__is_assignable(AllDeleted,
2260 AllDeleted &&)))]; }
2261 { int arr[T((__is_assignable(ExtDefaulted,
2262 const ExtDefaulted &)))]; }
2263 { int arr[T((__is_assignable(ExtDefaulted,
2264 ExtDefaulted &&)))]; }
2266 { int arr[T((__is_assignable(HasDefaultTrivialCopyAssign &,
2267 HasDefaultTrivialCopyAssign &)))]; }
2268 { int arr[T((__is_assignable(HasDefaultTrivialCopyAssign &,
2269 const HasDefaultTrivialCopyAssign &)))]; }
2270 { int arr[T((__is_assignable(TrivialMoveButNotCopy &,
2271 TrivialMoveButNotCopy)))]; }
2272 { int arr[T((__is_assignable(TrivialMoveButNotCopy &,
2273 TrivialMoveButNotCopy &&)))]; }
2275 { int arr[T(__is_assignable(ACompleteType, ACompleteType))]; }
2276 { int arr[F(__is_assignable(AnIncompleteType, AnIncompleteType))]; } // expected-error {{incomplete type}}
2277 { int arr[F(__is_assignable(AnIncompleteType[], AnIncompleteType[]))]; }
2278 { int arr[F(__is_assignable(AnIncompleteType[1], AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2279 { int arr[F(__is_assignable(void, void))]; }
2280 { int arr[F(__is_assignable(const volatile void, const volatile void))]; }
2283 void constructible_checks() {
2284 { int arr[T(__is_constructible(HasNoThrowConstructorWithArgs))]; }
2285 { int arr[F(__is_nothrow_constructible(HasNoThrowConstructorWithArgs))]; } // MSVC doesn't look into default args and gets this wrong.
2287 { int arr[T(__is_constructible(HasNoThrowConstructorWithArgs, HasCons))]; }
2288 { int arr[T(__is_nothrow_constructible(HasNoThrowConstructorWithArgs, HasCons))]; }
2290 { int arr[T(__is_constructible(NonTrivialDefault))]; }
2291 { int arr[F(__is_nothrow_constructible(NonTrivialDefault))]; }
2293 { int arr[T(__is_constructible(int))]; }
2294 { int arr[T(__is_nothrow_constructible(int))]; }
2296 { int arr[F(__is_constructible(NonPOD))]; }
2297 { int arr[F(__is_nothrow_constructible(NonPOD))]; }
2299 { int arr[T(__is_constructible(NonPOD, int))]; }
2300 { int arr[F(__is_nothrow_constructible(NonPOD, int))]; }
2302 // PR19178
2303 { int arr[F(__is_constructible(Abstract))]; }
2304 { int arr[F(__is_nothrow_constructible(Abstract))]; }
2306 // PR20228
2307 { int arr[T(__is_constructible(VariadicCtor,
2308 int, int, int, int, int, int, int, int, int))]; }
2310 // PR25513
2311 { int arr[F(__is_constructible(int(int)))]; }
2312 { int arr[T(__is_constructible(int const &, long))]; }
2314 { int arr[T(__is_constructible(ACompleteType))]; }
2315 { int arr[T(__is_nothrow_constructible(ACompleteType))]; }
2316 { int arr[F(__is_constructible(AnIncompleteType))]; } // expected-error {{incomplete type}}
2317 { int arr[F(__is_nothrow_constructible(AnIncompleteType))]; } // expected-error {{incomplete type}}
2318 { int arr[F(__is_constructible(AnIncompleteType[]))]; }
2319 { int arr[F(__is_nothrow_constructible(AnIncompleteType[]))]; }
2320 { int arr[F(__is_constructible(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2321 { int arr[F(__is_nothrow_constructible(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2322 { int arr[F(__is_constructible(void))]; }
2323 { int arr[F(__is_nothrow_constructible(void))]; }
2324 { int arr[F(__is_constructible(const volatile void))]; }
2325 { int arr[F(__is_nothrow_constructible(const volatile void))]; }
2328 // Instantiation of __is_trivially_constructible
2329 template<typename T, typename ...Args>
2330 struct is_trivially_constructible {
2331 static const bool value = __is_trivially_constructible(T, Args...);
2334 void is_trivially_constructible_test() {
2335 { int arr[T((is_trivially_constructible<int>::value))]; }
2336 { int arr[T((is_trivially_constructible<int, int>::value))]; }
2337 { int arr[T((is_trivially_constructible<int, float>::value))]; }
2338 { int arr[T((is_trivially_constructible<int, int&>::value))]; }
2339 { int arr[T((is_trivially_constructible<int, const int&>::value))]; }
2340 { int arr[T((is_trivially_constructible<int, int>::value))]; }
2341 { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign>::value))]; }
2342 { int arr[T((is_trivially_constructible<HasCopyAssign, const HasCopyAssign&>::value))]; }
2343 { int arr[T((is_trivially_constructible<HasCopyAssign, HasCopyAssign&&>::value))]; }
2344 { int arr[T((is_trivially_constructible<HasCopyAssign>::value))]; }
2345 { int arr[T((is_trivially_constructible<NonTrivialDefault,
2346 const NonTrivialDefault&>::value))]; }
2347 { int arr[T((is_trivially_constructible<NonTrivialDefault,
2348 NonTrivialDefault&&>::value))]; }
2350 { int arr[F((is_trivially_constructible<int, int*>::value))]; }
2351 { int arr[F((is_trivially_constructible<NonTrivialDefault>::value))]; }
2352 { int arr[F((is_trivially_constructible<ThreeArgCtor, int*, char*, int&>::value))]; }
2353 { int arr[F((is_trivially_constructible<Abstract>::value))]; } // PR19178
2355 { int arr[T(__is_trivially_constructible(ACompleteType))]; }
2356 { int arr[F(__is_trivially_constructible(AnIncompleteType))]; } // expected-error {{incomplete type}}
2357 { int arr[F(__is_trivially_constructible(AnIncompleteType[]))]; }
2358 { int arr[F(__is_trivially_constructible(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2359 { int arr[F(__is_trivially_constructible(void))]; }
2360 { int arr[F(__is_trivially_constructible(const volatile void))]; }
2363 template <class T, class RefType = T &>
2364 struct ConvertsToRef {
2365 operator RefType() const { return static_cast<RefType>(obj); }
2366 mutable T obj = 42;
2369 void reference_binds_to_temporary_checks() {
2370 { int arr[F((__reference_binds_to_temporary(int &, int &)))]; }
2371 { int arr[F((__reference_binds_to_temporary(int &, int &&)))]; }
2373 { int arr[F((__reference_binds_to_temporary(int const &, int &)))]; }
2374 { int arr[F((__reference_binds_to_temporary(int const &, int const &)))]; }
2375 { int arr[F((__reference_binds_to_temporary(int const &, int &&)))]; }
2377 { int arr[F((__reference_binds_to_temporary(int &, long &)))]; } // doesn't construct
2378 { int arr[T((__reference_binds_to_temporary(int const &, long &)))]; }
2379 { int arr[T((__reference_binds_to_temporary(int const &, long &&)))]; }
2380 { int arr[T((__reference_binds_to_temporary(int &&, long &)))]; }
2382 using LRef = ConvertsToRef<int, int &>;
2383 using RRef = ConvertsToRef<int, int &&>;
2384 using CLRef = ConvertsToRef<int, const int &>;
2385 using LongRef = ConvertsToRef<long, long &>;
2386 { int arr[T((__is_constructible(int &, LRef)))]; }
2387 { int arr[F((__reference_binds_to_temporary(int &, LRef)))]; }
2389 { int arr[T((__is_constructible(int &&, RRef)))]; }
2390 { int arr[F((__reference_binds_to_temporary(int &&, RRef)))]; }
2392 { int arr[T((__is_constructible(int const &, CLRef)))]; }
2393 { int arr[F((__reference_binds_to_temporary(int &&, CLRef)))]; }
2395 { int arr[T((__is_constructible(int const &, LongRef)))]; }
2396 { int arr[T((__reference_binds_to_temporary(int const &, LongRef)))]; }
2398 // Test that it doesn't accept non-reference types as input.
2399 { int arr[F((__reference_binds_to_temporary(int, long)))]; }
2401 { int arr[T((__reference_binds_to_temporary(const int &, long)))]; }
2404 void array_rank() {
2405 int t01[T(__array_rank(IntAr) == 1)];
2406 int t02[T(__array_rank(ConstIntArAr) == 2)];
2409 void array_extent() {
2410 int t01[T(__array_extent(IntAr, 0) == 10)];
2411 int t02[T(__array_extent(ConstIntArAr, 0) == 4)];
2412 int t03[T(__array_extent(ConstIntArAr, 1) == 10)];
2415 void is_destructible_test() {
2416 { int arr[T(__is_destructible(int))]; }
2417 { int arr[T(__is_destructible(int[2]))]; }
2418 { int arr[F(__is_destructible(int[]))]; }
2419 { int arr[F(__is_destructible(void))]; }
2420 { int arr[T(__is_destructible(int &))]; }
2421 { int arr[T(__is_destructible(HasDest))]; }
2422 { int arr[F(__is_destructible(AllPrivate))]; }
2423 { int arr[T(__is_destructible(SuperNonTrivialStruct))]; }
2424 { int arr[T(__is_destructible(AllDefaulted))]; }
2425 { int arr[F(__is_destructible(AllDeleted))]; }
2426 { int arr[T(__is_destructible(ThrowingDtor))]; }
2427 { int arr[T(__is_destructible(NoThrowDtor))]; }
2429 { int arr[T(__is_destructible(ACompleteType))]; }
2430 { int arr[F(__is_destructible(AnIncompleteType))]; } // expected-error {{incomplete type}}
2431 { int arr[F(__is_destructible(AnIncompleteType[]))]; }
2432 { int arr[F(__is_destructible(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2433 { int arr[F(__is_destructible(void))]; }
2434 { int arr[F(__is_destructible(const volatile void))]; }
2437 void is_nothrow_destructible_test() {
2438 { int arr[T(__is_nothrow_destructible(int))]; }
2439 { int arr[T(__is_nothrow_destructible(int[2]))]; }
2440 { int arr[F(__is_nothrow_destructible(int[]))]; }
2441 { int arr[F(__is_nothrow_destructible(void))]; }
2442 { int arr[T(__is_nothrow_destructible(int &))]; }
2443 { int arr[T(__is_nothrow_destructible(HasDest))]; }
2444 { int arr[F(__is_nothrow_destructible(AllPrivate))]; }
2445 { int arr[T(__is_nothrow_destructible(SuperNonTrivialStruct))]; }
2446 { int arr[T(__is_nothrow_destructible(AllDefaulted))]; }
2447 { int arr[F(__is_nothrow_destructible(AllDeleted))]; }
2448 { int arr[F(__is_nothrow_destructible(ThrowingDtor))]; }
2449 { int arr[T(__is_nothrow_destructible(NoExceptDtor))]; }
2450 { int arr[T(__is_nothrow_destructible(NoThrowDtor))]; }
2452 { int arr[T(__is_nothrow_destructible(ACompleteType))]; }
2453 { int arr[F(__is_nothrow_destructible(AnIncompleteType))]; } // expected-error {{incomplete type}}
2454 { int arr[F(__is_nothrow_destructible(AnIncompleteType[]))]; }
2455 { int arr[F(__is_nothrow_destructible(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2456 { int arr[F(__is_nothrow_destructible(void))]; }
2457 { int arr[F(__is_nothrow_destructible(const volatile void))]; }
2460 void is_trivially_destructible_test() {
2461 { int arr[T(__is_trivially_destructible(int))]; }
2462 { int arr[T(__is_trivially_destructible(int[2]))]; }
2463 { int arr[F(__is_trivially_destructible(int[]))]; }
2464 { int arr[F(__is_trivially_destructible(void))]; }
2465 { int arr[T(__is_trivially_destructible(int &))]; }
2466 { int arr[F(__is_trivially_destructible(HasDest))]; }
2467 { int arr[F(__is_trivially_destructible(AllPrivate))]; }
2468 { int arr[F(__is_trivially_destructible(SuperNonTrivialStruct))]; }
2469 { int arr[T(__is_trivially_destructible(AllDefaulted))]; }
2470 { int arr[F(__is_trivially_destructible(AllDeleted))]; }
2471 { int arr[F(__is_trivially_destructible(ThrowingDtor))]; }
2472 { int arr[F(__is_trivially_destructible(NoThrowDtor))]; }
2474 { int arr[T(__is_trivially_destructible(ACompleteType))]; }
2475 { int arr[F(__is_trivially_destructible(AnIncompleteType))]; } // expected-error {{incomplete type}}
2476 { int arr[F(__is_trivially_destructible(AnIncompleteType[]))]; }
2477 { int arr[F(__is_trivially_destructible(AnIncompleteType[1]))]; } // expected-error {{incomplete type}}
2478 { int arr[F(__is_trivially_destructible(void))]; }
2479 { int arr[F(__is_trivially_destructible(const volatile void))]; }
2482 // Instantiation of __has_unique_object_representations
2483 template <typename T>
2484 struct has_unique_object_representations {
2485 static const bool value = __has_unique_object_representations(T);
2488 static_assert(!has_unique_object_representations<void>::value, "void is never unique");
2489 static_assert(!has_unique_object_representations<const void>::value, "void is never unique");
2490 static_assert(!has_unique_object_representations<volatile void>::value, "void is never unique");
2491 static_assert(!has_unique_object_representations<const volatile void>::value, "void is never unique");
2493 static_assert(has_unique_object_representations<int>::value, "integrals are");
2494 static_assert(has_unique_object_representations<const int>::value, "integrals are");
2495 static_assert(has_unique_object_representations<volatile int>::value, "integrals are");
2496 static_assert(has_unique_object_representations<const volatile int>::value, "integrals are");
2498 static_assert(has_unique_object_representations<void *>::value, "as are pointers");
2499 static_assert(has_unique_object_representations<const void *>::value, "as are pointers");
2500 static_assert(has_unique_object_representations<volatile void *>::value, "are pointers");
2501 static_assert(has_unique_object_representations<const volatile void *>::value, "as are pointers");
2503 static_assert(has_unique_object_representations<int *>::value, "as are pointers");
2504 static_assert(has_unique_object_representations<const int *>::value, "as are pointers");
2505 static_assert(has_unique_object_representations<volatile int *>::value, "as are pointers");
2506 static_assert(has_unique_object_representations<const volatile int *>::value, "as are pointers");
2508 class C {};
2509 using FP = int (*)(int);
2510 using PMF = int (C::*)(int);
2511 using PMD = int C::*;
2513 static_assert(has_unique_object_representations<FP>::value, "even function pointers");
2514 static_assert(has_unique_object_representations<const FP>::value, "even function pointers");
2515 static_assert(has_unique_object_representations<volatile FP>::value, "even function pointers");
2516 static_assert(has_unique_object_representations<const volatile FP>::value, "even function pointers");
2518 static_assert(has_unique_object_representations<PMF>::value, "and pointer to members");
2519 static_assert(has_unique_object_representations<const PMF>::value, "and pointer to members");
2520 static_assert(has_unique_object_representations<volatile PMF>::value, "and pointer to members");
2521 static_assert(has_unique_object_representations<const volatile PMF>::value, "and pointer to members");
2523 static_assert(has_unique_object_representations<PMD>::value, "and pointer to members");
2524 static_assert(has_unique_object_representations<const PMD>::value, "and pointer to members");
2525 static_assert(has_unique_object_representations<volatile PMD>::value, "and pointer to members");
2526 static_assert(has_unique_object_representations<const volatile PMD>::value, "and pointer to members");
2528 static_assert(has_unique_object_representations<bool>::value, "yes, all integral types");
2529 static_assert(has_unique_object_representations<char>::value, "yes, all integral types");
2530 static_assert(has_unique_object_representations<signed char>::value, "yes, all integral types");
2531 static_assert(has_unique_object_representations<unsigned char>::value, "yes, all integral types");
2532 static_assert(has_unique_object_representations<short>::value, "yes, all integral types");
2533 static_assert(has_unique_object_representations<unsigned short>::value, "yes, all integral types");
2534 static_assert(has_unique_object_representations<int>::value, "yes, all integral types");
2535 static_assert(has_unique_object_representations<unsigned int>::value, "yes, all integral types");
2536 static_assert(has_unique_object_representations<long>::value, "yes, all integral types");
2537 static_assert(has_unique_object_representations<unsigned long>::value, "yes, all integral types");
2538 static_assert(has_unique_object_representations<long long>::value, "yes, all integral types");
2539 static_assert(has_unique_object_representations<unsigned long long>::value, "yes, all integral types");
2540 static_assert(has_unique_object_representations<wchar_t>::value, "yes, all integral types");
2541 static_assert(has_unique_object_representations<char16_t>::value, "yes, all integral types");
2542 static_assert(has_unique_object_representations<char32_t>::value, "yes, all integral types");
2544 static_assert(!has_unique_object_representations<void>::value, "but not void!");
2545 static_assert(!has_unique_object_representations<decltype(nullptr)>::value, "or nullptr_t");
2546 static_assert(!has_unique_object_representations<float>::value, "definitely not Floating Point");
2547 static_assert(!has_unique_object_representations<double>::value, "definitely not Floating Point");
2548 static_assert(!has_unique_object_representations<long double>::value, "definitely not Floating Point");
2550 struct NoPadding {
2551 int a;
2552 int b;
2555 static_assert(has_unique_object_representations<NoPadding>::value, "types without padding are");
2557 struct InheritsFromNoPadding : NoPadding {
2558 int c;
2559 int d;
2562 static_assert(has_unique_object_representations<InheritsFromNoPadding>::value, "types without padding are");
2564 struct VirtuallyInheritsFromNoPadding : virtual NoPadding {
2565 int c;
2566 int d;
2569 static_assert(!has_unique_object_representations<VirtuallyInheritsFromNoPadding>::value, "No virtual inheritance");
2571 struct Padding {
2572 char a;
2573 int b;
2576 //static_assert(!has_unique_object_representations<Padding>::value, "but not with padding");
2578 struct InheritsFromPadding : Padding {
2579 int c;
2580 int d;
2583 static_assert(!has_unique_object_representations<InheritsFromPadding>::value, "or its subclasses");
2585 struct TailPadding {
2586 int a;
2587 char b;
2590 static_assert(!has_unique_object_representations<TailPadding>::value, "even at the end");
2592 struct TinyStruct {
2593 char a;
2596 static_assert(has_unique_object_representations<TinyStruct>::value, "Should be no padding");
2598 struct InheritsFromTinyStruct : TinyStruct {
2599 int b;
2602 static_assert(!has_unique_object_representations<InheritsFromTinyStruct>::value, "Inherit causes padding");
2604 union NoPaddingUnion {
2605 int a;
2606 unsigned int b;
2609 static_assert(has_unique_object_representations<NoPaddingUnion>::value, "unions follow the same rules as structs");
2611 union PaddingUnion {
2612 int a;
2613 long long b;
2616 static_assert(!has_unique_object_representations<PaddingUnion>::value, "unions follow the same rules as structs");
2618 struct NotTriviallyCopyable {
2619 int x;
2620 NotTriviallyCopyable(const NotTriviallyCopyable &) {}
2623 static_assert(!has_unique_object_representations<NotTriviallyCopyable>::value, "must be trivially copyable");
2625 struct HasNonUniqueMember {
2626 float x;
2629 static_assert(!has_unique_object_representations<HasNonUniqueMember>::value, "all members must be unique");
2631 enum ExampleEnum { xExample,
2632 yExample };
2633 enum LLEnum : long long { xLongExample,
2634 yLongExample };
2636 static_assert(has_unique_object_representations<ExampleEnum>::value, "Enums are integrals, so unique!");
2637 static_assert(has_unique_object_representations<LLEnum>::value, "Enums are integrals, so unique!");
2639 enum class ExampleEnumClass { xExample,
2640 yExample };
2641 enum class LLEnumClass : long long { xLongExample,
2642 yLongExample };
2644 static_assert(has_unique_object_representations<ExampleEnumClass>::value, "Enums are integrals, so unique!");
2645 static_assert(has_unique_object_representations<LLEnumClass>::value, "Enums are integrals, so unique!");
2647 // because references aren't trivially copyable.
2648 static_assert(!has_unique_object_representations<int &>::value, "No references!");
2649 static_assert(!has_unique_object_representations<const int &>::value, "No references!");
2650 static_assert(!has_unique_object_representations<volatile int &>::value, "No references!");
2651 static_assert(!has_unique_object_representations<const volatile int &>::value, "No references!");
2652 static_assert(!has_unique_object_representations<Empty>::value, "No empty types!");
2653 static_assert(!has_unique_object_representations<EmptyUnion>::value, "No empty types!");
2655 class Compressed : Empty {
2656 int x;
2659 static_assert(has_unique_object_representations<Compressed>::value, "But inheriting from one is ok");
2661 class EmptyInheritor : Compressed {};
2663 static_assert(has_unique_object_representations<EmptyInheritor>::value, "As long as the base has items, empty is ok");
2665 class Dynamic {
2666 virtual void A();
2667 int i;
2670 static_assert(!has_unique_object_representations<Dynamic>::value, "Dynamic types are not valid");
2672 class InheritsDynamic : Dynamic {
2673 int j;
2676 static_assert(!has_unique_object_representations<InheritsDynamic>::value, "Dynamic types are not valid");
2678 static_assert(has_unique_object_representations<int[42]>::value, "Arrays are fine, as long as their value type is");
2679 static_assert(has_unique_object_representations<int[]>::value, "Arrays are fine, as long as their value type is");
2680 static_assert(has_unique_object_representations<int[][42]>::value, "Arrays are fine, as long as their value type is");
2681 static_assert(!has_unique_object_representations<double[42]>::value, "So no array of doubles!");
2682 static_assert(!has_unique_object_representations<double[]>::value, "So no array of doubles!");
2683 static_assert(!has_unique_object_representations<double[][42]>::value, "So no array of doubles!");
2685 struct __attribute__((aligned(16))) WeirdAlignment {
2686 int i;
2688 union __attribute__((aligned(16))) WeirdAlignmentUnion {
2689 int i;
2691 static_assert(!has_unique_object_representations<WeirdAlignment>::value, "Alignment causes padding");
2692 static_assert(!has_unique_object_representations<WeirdAlignmentUnion>::value, "Alignment causes padding");
2693 static_assert(!has_unique_object_representations<WeirdAlignment[42]>::value, "Also no arrays that have padding");
2695 static_assert(!has_unique_object_representations<int(int)>::value, "Functions are not unique");
2696 static_assert(!has_unique_object_representations<int(int) const>::value, "Functions are not unique");
2697 static_assert(!has_unique_object_representations<int(int) volatile>::value, "Functions are not unique");
2698 static_assert(!has_unique_object_representations<int(int) const volatile>::value, "Functions are not unique");
2699 static_assert(!has_unique_object_representations<int(int) &>::value, "Functions are not unique");
2700 static_assert(!has_unique_object_representations<int(int) const &>::value, "Functions are not unique");
2701 static_assert(!has_unique_object_representations<int(int) volatile &>::value, "Functions are not unique");
2702 static_assert(!has_unique_object_representations<int(int) const volatile &>::value, "Functions are not unique");
2703 static_assert(!has_unique_object_representations<int(int) &&>::value, "Functions are not unique");
2704 static_assert(!has_unique_object_representations<int(int) const &&>::value, "Functions are not unique");
2705 static_assert(!has_unique_object_representations<int(int) volatile &&>::value, "Functions are not unique");
2706 static_assert(!has_unique_object_representations<int(int) const volatile &&>::value, "Functions are not unique");
2708 static_assert(!has_unique_object_representations<int(int, ...)>::value, "Functions are not unique");
2709 static_assert(!has_unique_object_representations<int(int, ...) const>::value, "Functions are not unique");
2710 static_assert(!has_unique_object_representations<int(int, ...) volatile>::value, "Functions are not unique");
2711 static_assert(!has_unique_object_representations<int(int, ...) const volatile>::value, "Functions are not unique");
2712 static_assert(!has_unique_object_representations<int(int, ...) &>::value, "Functions are not unique");
2713 static_assert(!has_unique_object_representations<int(int, ...) const &>::value, "Functions are not unique");
2714 static_assert(!has_unique_object_representations<int(int, ...) volatile &>::value, "Functions are not unique");
2715 static_assert(!has_unique_object_representations<int(int, ...) const volatile &>::value, "Functions are not unique");
2716 static_assert(!has_unique_object_representations<int(int, ...) &&>::value, "Functions are not unique");
2717 static_assert(!has_unique_object_representations<int(int, ...) const &&>::value, "Functions are not unique");
2718 static_assert(!has_unique_object_representations<int(int, ...) volatile &&>::value, "Functions are not unique");
2719 static_assert(!has_unique_object_representations<int(int, ...) const volatile &&>::value, "Functions are not unique");
2721 void foo(){
2722 static auto lambda = []() {};
2723 static_assert(!has_unique_object_representations<decltype(lambda)>::value, "Lambdas follow struct rules");
2724 int i;
2725 static auto lambda2 = [i]() {};
2726 static_assert(has_unique_object_representations<decltype(lambda2)>::value, "Lambdas follow struct rules");
2729 struct PaddedBitfield {
2730 char c : 6;
2731 char d : 1;
2734 struct UnPaddedBitfield {
2735 char c : 6;
2736 char d : 2;
2739 struct AlignedPaddedBitfield {
2740 char c : 6;
2741 __attribute__((aligned(1)))
2742 char d : 2;
2745 static_assert(!has_unique_object_representations<PaddedBitfield>::value, "Bitfield padding");
2746 static_assert(has_unique_object_representations<UnPaddedBitfield>::value, "Bitfield padding");
2747 static_assert(!has_unique_object_representations<AlignedPaddedBitfield>::value, "Bitfield padding");
2749 struct BoolBitfield {
2750 bool b : 8;
2753 static_assert(has_unique_object_representations<BoolBitfield>::value, "Bitfield bool");
2755 struct BoolBitfield2 {
2756 bool b : 16;
2759 static_assert(!has_unique_object_representations<BoolBitfield2>::value, "Bitfield bool");
2761 struct GreaterSizeBitfield {
2762 //expected-warning@+1 {{width of bit-field 'n'}}
2763 int n : 1024;
2766 static_assert(sizeof(GreaterSizeBitfield) == 128, "Bitfield Size");
2767 static_assert(!has_unique_object_representations<GreaterSizeBitfield>::value, "Bitfield padding");
2769 struct StructWithRef {
2770 int &I;
2773 static_assert(has_unique_object_representations<StructWithRef>::value, "References are still unique");
2775 struct NotUniqueBecauseTailPadding {
2776 int &r;
2777 char a;
2779 struct CanBeUniqueIfNoPadding : NotUniqueBecauseTailPadding {
2780 char b[7];
2783 static_assert(!has_unique_object_representations<NotUniqueBecauseTailPadding>::value,
2784 "non trivial");
2785 // Can be unique on Itanium, since the is child class' data is 'folded' into the
2786 // parent's tail padding.
2787 static_assert(sizeof(CanBeUniqueIfNoPadding) != 16 ||
2788 has_unique_object_representations<CanBeUniqueIfNoPadding>::value,
2789 "inherit from std layout");
2791 namespace ErrorType {
2792 struct S; //expected-note{{forward declaration of 'ErrorType::S'}}
2794 struct T {
2795 S t; //expected-error{{field has incomplete type 'S'}}
2797 bool b = __has_unique_object_representations(T);
2800 namespace PR46209 {
2801 // Foo has both a trivial assignment operator and a non-trivial one.
2802 struct Foo {
2803 Foo &operator=(const Foo &) & { return *this; }
2804 Foo &operator=(const Foo &) && = default;
2807 // Bar's copy assignment calls Foo's non-trivial assignment.
2808 struct Bar {
2809 Foo foo;
2812 static_assert(!__is_trivially_assignable(Foo &, const Foo &), "");
2813 static_assert(!__is_trivially_assignable(Bar &, const Bar &), "");
2815 // Foo2 has both a trivial assignment operator and a non-trivial one.
2816 struct Foo2 {
2817 Foo2 &operator=(const Foo2 &) & = default;
2818 Foo2 &operator=(const Foo2 &) && { return *this; }
2821 // Bar2's copy assignment calls Foo2's trivial assignment.
2822 struct Bar2 {
2823 Foo2 foo;
2826 static_assert(__is_trivially_assignable(Foo2 &, const Foo2 &), "");
2827 static_assert(__is_trivially_assignable(Bar2 &, const Bar2 &), "");
2830 namespace ConstClass {
2831 struct A {
2832 A &operator=(const A&) = default;
2834 struct B {
2835 const A a;
2837 static_assert(!__is_trivially_assignable(B&, const B&), "");
2840 namespace type_trait_expr_numargs_overflow {
2841 // Make sure that TypeTraitExpr can store 16 bits worth of arguments.
2842 #define T4(X) X,X,X,X
2843 #define T16(X) T4(X),T4(X),T4(X),T4(X)
2844 #define T64(X) T16(X),T16(X),T16(X),T16(X)
2845 #define T256(X) T64(X),T64(X),T64(X),T64(X)
2846 #define T1024(X) T256(X),T256(X),T256(X),T256(X)
2847 #define T4096(X) T1024(X),T1024(X),T1024(X),T1024(X)
2848 #define T16384(X) T4096(X),T4096(X),T4096(X),T4096(X)
2849 #define T32768(X) T16384(X),T16384(X)
2850 void test() { (void) __is_constructible(int, T32768(int)); }
2851 #undef T4
2852 #undef T16
2853 #undef T64
2854 #undef T256
2855 #undef T1024
2856 #undef T4096
2857 #undef T16384
2858 #undef T32768
2859 } // namespace type_trait_expr_numargs_overflow
2861 namespace is_trivially_relocatable {
2863 static_assert(!__is_trivially_relocatable(void), "");
2864 static_assert(__is_trivially_relocatable(int), "");
2865 static_assert(__is_trivially_relocatable(int[]), "");
2867 enum Enum {};
2868 static_assert(__is_trivially_relocatable(Enum), "");
2869 static_assert(__is_trivially_relocatable(Enum[]), "");
2871 union Union {int x;};
2872 static_assert(__is_trivially_relocatable(Union), "");
2873 static_assert(__is_trivially_relocatable(Union[]), "");
2875 struct Trivial {};
2876 static_assert(__is_trivially_relocatable(Trivial), "");
2877 static_assert(__is_trivially_relocatable(Trivial[]), "");
2879 struct Incomplete; // expected-note {{forward declaration of 'is_trivially_relocatable::Incomplete'}}
2880 bool unused = __is_trivially_relocatable(Incomplete); // expected-error {{incomplete type}}
2882 struct NontrivialDtor {
2883 ~NontrivialDtor() {}
2885 static_assert(!__is_trivially_relocatable(NontrivialDtor), "");
2886 static_assert(!__is_trivially_relocatable(NontrivialDtor[]), "");
2888 struct NontrivialCopyCtor {
2889 NontrivialCopyCtor(const NontrivialCopyCtor&) {}
2891 static_assert(!__is_trivially_relocatable(NontrivialCopyCtor), "");
2892 static_assert(!__is_trivially_relocatable(NontrivialCopyCtor[]), "");
2894 struct NontrivialMoveCtor {
2895 NontrivialMoveCtor(NontrivialMoveCtor&&) {}
2897 static_assert(!__is_trivially_relocatable(NontrivialMoveCtor), "");
2898 static_assert(!__is_trivially_relocatable(NontrivialMoveCtor[]), "");
2900 struct [[clang::trivial_abi]] TrivialAbiNontrivialDtor {
2901 ~TrivialAbiNontrivialDtor() {}
2903 static_assert(__is_trivially_relocatable(TrivialAbiNontrivialDtor), "");
2904 static_assert(__is_trivially_relocatable(TrivialAbiNontrivialDtor[]), "");
2906 struct [[clang::trivial_abi]] TrivialAbiNontrivialCopyCtor {
2907 TrivialAbiNontrivialCopyCtor(const TrivialAbiNontrivialCopyCtor&) {}
2909 static_assert(__is_trivially_relocatable(TrivialAbiNontrivialCopyCtor), "");
2910 static_assert(__is_trivially_relocatable(TrivialAbiNontrivialCopyCtor[]), "");
2912 // A more complete set of tests for the behavior of trivial_abi can be found in
2913 // clang/test/SemaCXX/attr-trivial-abi.cpp
2914 struct [[clang::trivial_abi]] TrivialAbiNontrivialMoveCtor {
2915 TrivialAbiNontrivialMoveCtor(TrivialAbiNontrivialMoveCtor&&) {}
2917 static_assert(__is_trivially_relocatable(TrivialAbiNontrivialMoveCtor), "");
2918 static_assert(__is_trivially_relocatable(TrivialAbiNontrivialMoveCtor[]), "");
2920 } // namespace is_trivially_relocatable
2922 struct S {};
2923 template <class T> using remove_const_t = __remove_const(T);
2925 void check_remove_const() {
2926 static_assert(__is_same(remove_const_t<void>, void), "");
2927 static_assert(__is_same(remove_const_t<const void>, void), "");
2928 static_assert(__is_same(remove_const_t<int>, int), "");
2929 static_assert(__is_same(remove_const_t<const int>, int), "");
2930 static_assert(__is_same(remove_const_t<volatile int>, volatile int), "");
2931 static_assert(__is_same(remove_const_t<const volatile int>, volatile int), "");
2932 static_assert(__is_same(remove_const_t<int *>, int *), "");
2933 static_assert(__is_same(remove_const_t<int *const>, int *), "");
2934 static_assert(__is_same(remove_const_t<int const *const>, int const *), "");
2935 static_assert(__is_same(remove_const_t<int const *const __restrict>, int const *__restrict), "");
2936 static_assert(__is_same(remove_const_t<int &>, int &), "");
2937 static_assert(__is_same(remove_const_t<int const &>, int const &), "");
2938 static_assert(__is_same(remove_const_t<int &&>, int &&), "");
2939 static_assert(__is_same(remove_const_t<int const &&>, int const &&), "");
2940 static_assert(__is_same(remove_const_t<int()>, int()), "");
2941 static_assert(__is_same(remove_const_t<int (*const)()>, int (*)()), "");
2942 static_assert(__is_same(remove_const_t<int (&)()>, int (&)()), "");
2944 static_assert(__is_same(remove_const_t<S>, S), "");
2945 static_assert(__is_same(remove_const_t<const S>, S), "");
2946 static_assert(__is_same(remove_const_t<volatile S>, volatile S), "");
2947 static_assert(__is_same(remove_const_t<S *__restrict>, S *__restrict), "");
2948 static_assert(__is_same(remove_const_t<const volatile S>, volatile S), "");
2949 static_assert(__is_same(remove_const_t<S *const volatile __restrict>, S *volatile __restrict), "");
2950 static_assert(__is_same(remove_const_t<int S::*const>, int S::*), "");
2951 static_assert(__is_same(remove_const_t<int (S::*const)()>, int(S::*)()), "");
2954 template <class T> using remove_restrict_t = __remove_restrict(T);
2956 void check_remove_restrict() {
2957 static_assert(__is_same(remove_restrict_t<void>, void), "");
2958 static_assert(__is_same(remove_restrict_t<int>, int), "");
2959 static_assert(__is_same(remove_restrict_t<const int>, const int), "");
2960 static_assert(__is_same(remove_restrict_t<volatile int>, volatile int), "");
2961 static_assert(__is_same(remove_restrict_t<int *__restrict>, int *), "");
2962 static_assert(__is_same(remove_restrict_t<int *const volatile __restrict>, int *const volatile), "");
2963 static_assert(__is_same(remove_restrict_t<int *>, int *), "");
2964 static_assert(__is_same(remove_restrict_t<int *__restrict>, int *), "");
2965 static_assert(__is_same(remove_restrict_t<int &>, int &), "");
2966 static_assert(__is_same(remove_restrict_t<int &__restrict>, int &), "");
2967 static_assert(__is_same(remove_restrict_t<int &&>, int &&), "");
2968 static_assert(__is_same(remove_restrict_t<int &&__restrict>, int &&), "");
2969 static_assert(__is_same(remove_restrict_t<int()>, int()), "");
2970 static_assert(__is_same(remove_restrict_t<int (*const volatile)()>, int (*const volatile)()), "");
2971 static_assert(__is_same(remove_restrict_t<int (&)()>, int (&)()), "");
2973 static_assert(__is_same(remove_restrict_t<S>, S), "");
2974 static_assert(__is_same(remove_restrict_t<const S>, const S), "");
2975 static_assert(__is_same(remove_restrict_t<volatile S>, volatile S), "");
2976 static_assert(__is_same(remove_restrict_t<S *__restrict>, S *), "");
2977 static_assert(__is_same(remove_restrict_t<S *const volatile __restrict>, S *const volatile), "");
2978 static_assert(__is_same(remove_restrict_t<int S::*__restrict>, int S::*), "");
2979 static_assert(__is_same(remove_restrict_t<int (S::*const volatile)()>, int(S::*const volatile)()), "");
2982 template <class T> using remove_volatile_t = __remove_volatile(T);
2984 void check_remove_volatile() {
2985 static_assert(__is_same(remove_volatile_t<void>, void), "");
2986 static_assert(__is_same(remove_volatile_t<volatile void>, void), "");
2987 static_assert(__is_same(remove_volatile_t<int>, int), "");
2988 static_assert(__is_same(remove_volatile_t<const int>, const int), "");
2989 static_assert(__is_same(remove_volatile_t<volatile int>, int), "");
2990 static_assert(__is_same(remove_volatile_t<int *__restrict>, int *__restrict), "");
2991 static_assert(__is_same(remove_volatile_t<const volatile int>, const int), "");
2992 static_assert(__is_same(remove_volatile_t<int *const volatile __restrict>, int *const __restrict), "");
2993 static_assert(__is_same(remove_volatile_t<int *>, int *), "");
2994 static_assert(__is_same(remove_volatile_t<int *volatile>, int *), "");
2995 static_assert(__is_same(remove_volatile_t<int volatile *volatile>, int volatile *), "");
2996 static_assert(__is_same(remove_volatile_t<int &>, int &), "");
2997 static_assert(__is_same(remove_volatile_t<int volatile &>, int volatile &), "");
2998 static_assert(__is_same(remove_volatile_t<int &&>, int &&), "");
2999 static_assert(__is_same(remove_volatile_t<int volatile &&>, int volatile &&), "");
3000 static_assert(__is_same(remove_volatile_t<int()>, int()), "");
3001 static_assert(__is_same(remove_volatile_t<int (*volatile)()>, int (*)()), "");
3002 static_assert(__is_same(remove_volatile_t<int (&)()>, int (&)()), "");
3004 static_assert(__is_same(remove_volatile_t<S>, S), "");
3005 static_assert(__is_same(remove_volatile_t<const S>, const S), "");
3006 static_assert(__is_same(remove_volatile_t<volatile S>, S), "");
3007 static_assert(__is_same(remove_volatile_t<const volatile S>, const S), "");
3008 static_assert(__is_same(remove_volatile_t<int S::*volatile>, int S::*), "");
3009 static_assert(__is_same(remove_volatile_t<int (S::*volatile)()>, int(S::*)()), "");
3012 template <class T> using remove_cv_t = __remove_cv(T);
3014 void check_remove_cv() {
3015 static_assert(__is_same(remove_cv_t<void>, void), "");
3016 static_assert(__is_same(remove_cv_t<const volatile void>, void), "");
3017 static_assert(__is_same(remove_cv_t<int>, int), "");
3018 static_assert(__is_same(remove_cv_t<const int>, int), "");
3019 static_assert(__is_same(remove_cv_t<volatile int>, int), "");
3020 static_assert(__is_same(remove_cv_t<const volatile int>, int), "");
3021 static_assert(__is_same(remove_cv_t<int *>, int *), "");
3022 static_assert(__is_same(remove_cv_t<int *const volatile>, int *), "");
3023 static_assert(__is_same(remove_cv_t<int const *const volatile>, int const *), "");
3024 static_assert(__is_same(remove_cv_t<int const *const volatile __restrict>, int const *__restrict), "");
3025 static_assert(__is_same(remove_cv_t<int const *const volatile _Nonnull>, int const *_Nonnull), "");
3026 static_assert(__is_same(remove_cv_t<int &>, int &), "");
3027 static_assert(__is_same(remove_cv_t<int const volatile &>, int const volatile &), "");
3028 static_assert(__is_same(remove_cv_t<int &&>, int &&), "");
3029 static_assert(__is_same(remove_cv_t<int const volatile &&>, int const volatile &&), "");
3030 static_assert(__is_same(remove_cv_t<int()>, int()), "");
3031 static_assert(__is_same(remove_cv_t<int (*const volatile)()>, int (*)()), "");
3032 static_assert(__is_same(remove_cv_t<int (&)()>, int (&)()), "");
3034 static_assert(__is_same(remove_cv_t<S>, S), "");
3035 static_assert(__is_same(remove_cv_t<const S>, S), "");
3036 static_assert(__is_same(remove_cv_t<volatile S>, S), "");
3037 static_assert(__is_same(remove_cv_t<const volatile S>, S), "");
3038 static_assert(__is_same(remove_cv_t<int S::*const volatile>, int S::*), "");
3039 static_assert(__is_same(remove_cv_t<int (S::*const volatile)()>, int(S::*)()), "");
3042 template <class T> using add_pointer_t = __add_pointer(T);
3044 void add_pointer() {
3045 static_assert(__is_same(add_pointer_t<void>, void *), "");
3046 static_assert(__is_same(add_pointer_t<const void>, const void *), "");
3047 static_assert(__is_same(add_pointer_t<volatile void>, volatile void *), "");
3048 static_assert(__is_same(add_pointer_t<const volatile void>, const volatile void *), "");
3049 static_assert(__is_same(add_pointer_t<int>, int *), "");
3050 static_assert(__is_same(add_pointer_t<const int>, const int *), "");
3051 static_assert(__is_same(add_pointer_t<volatile int>, volatile int *), "");
3052 static_assert(__is_same(add_pointer_t<const volatile int>, const volatile int *), "");
3053 static_assert(__is_same(add_pointer_t<int *>, int **), "");
3054 static_assert(__is_same(add_pointer_t<int &>, int *), "");
3055 static_assert(__is_same(add_pointer_t<int &&>, int *), "");
3056 static_assert(__is_same(add_pointer_t<int()>, int (*)()), "");
3057 static_assert(__is_same(add_pointer_t<int (*)()>, int (**)()), "");
3058 static_assert(__is_same(add_pointer_t<int (&)()>, int (*)()), "");
3060 static_assert(__is_same(add_pointer_t<S>, S *), "");
3061 static_assert(__is_same(add_pointer_t<const S>, const S *), "");
3062 static_assert(__is_same(add_pointer_t<volatile S>, volatile S *), "");
3063 static_assert(__is_same(add_pointer_t<const volatile S>, const volatile S *), "");
3064 static_assert(__is_same(add_pointer_t<int S::*>, int S::**), "");
3065 static_assert(__is_same(add_pointer_t<int (S::*)()>, int(S::**)()), "");
3067 static_assert(__is_same(add_pointer_t<int __attribute__((address_space(1)))>, int __attribute__((address_space(1))) *), "");
3068 static_assert(__is_same(add_pointer_t<S __attribute__((address_space(2)))>, S __attribute__((address_space(2))) *), "");
3071 template <class T> using remove_pointer_t = __remove_pointer(T);
3073 void remove_pointer() {
3074 static_assert(__is_same(remove_pointer_t<void>, void), "");
3075 static_assert(__is_same(remove_pointer_t<const void>, const void), "");
3076 static_assert(__is_same(remove_pointer_t<volatile void>, volatile void), "");
3077 static_assert(__is_same(remove_pointer_t<const volatile void>, const volatile void), "");
3078 static_assert(__is_same(remove_pointer_t<int>, int), "");
3079 static_assert(__is_same(remove_pointer_t<const int>, const int), "");
3080 static_assert(__is_same(remove_pointer_t<volatile int>, volatile int), "");
3081 static_assert(__is_same(remove_pointer_t<const volatile int>, const volatile int), "");
3082 static_assert(__is_same(remove_pointer_t<int *>, int), "");
3083 static_assert(__is_same(remove_pointer_t<const int *>, const int), "");
3084 static_assert(__is_same(remove_pointer_t<volatile int *>, volatile int), "");
3085 static_assert(__is_same(remove_pointer_t<const volatile int *>, const volatile int), "");
3086 static_assert(__is_same(remove_pointer_t<int *const>, int), "");
3087 static_assert(__is_same(remove_pointer_t<int *volatile>, int), "");
3088 static_assert(__is_same(remove_pointer_t<int *const volatile>, int), "");
3089 static_assert(__is_same(remove_pointer_t<int &>, int &), "");
3090 static_assert(__is_same(remove_pointer_t<int &&>, int &&), "");
3091 static_assert(__is_same(remove_pointer_t<int()>, int()), "");
3092 static_assert(__is_same(remove_pointer_t<int (*)()>, int()), "");
3093 static_assert(__is_same(remove_pointer_t<int (&)()>, int (&)()), "");
3095 static_assert(__is_same(remove_pointer_t<S>, S), "");
3096 static_assert(__is_same(remove_pointer_t<const S>, const S), "");
3097 static_assert(__is_same(remove_pointer_t<volatile S>, volatile S), "");
3098 static_assert(__is_same(remove_pointer_t<const volatile S>, const volatile S), "");
3099 static_assert(__is_same(remove_pointer_t<int S::*>, int S::*), "");
3100 static_assert(__is_same(remove_pointer_t<int (S::*)()>, int(S::*)()), "");
3102 static_assert(__is_same(remove_pointer_t<int __attribute__((address_space(1))) *>, int __attribute__((address_space(1)))), "");
3103 static_assert(__is_same(remove_pointer_t<S __attribute__((address_space(2))) *>, S __attribute__((address_space(2)))), "");
3105 static_assert(__is_same(remove_pointer_t<int (^)(char)>, int (^)(char)), "");
3108 template <class T> using add_lvalue_reference_t = __add_lvalue_reference(T);
3110 void add_lvalue_reference() {
3111 static_assert(__is_same(add_lvalue_reference_t<void>, void), "");
3112 static_assert(__is_same(add_lvalue_reference_t<const void>, const void), "");
3113 static_assert(__is_same(add_lvalue_reference_t<volatile void>, volatile void), "");
3114 static_assert(__is_same(add_lvalue_reference_t<const volatile void>, const volatile void), "");
3115 static_assert(__is_same(add_lvalue_reference_t<int>, int &), "");
3116 static_assert(__is_same(add_lvalue_reference_t<const int>, const int &), "");
3117 static_assert(__is_same(add_lvalue_reference_t<volatile int>, volatile int &), "");
3118 static_assert(__is_same(add_lvalue_reference_t<const volatile int>, const volatile int &), "");
3119 static_assert(__is_same(add_lvalue_reference_t<int *>, int *&), "");
3120 static_assert(__is_same(add_lvalue_reference_t<int &>, int &), "");
3121 static_assert(__is_same(add_lvalue_reference_t<int &&>, int &), ""); // reference collapsing
3122 static_assert(__is_same(add_lvalue_reference_t<int()>, int (&)()), "");
3123 static_assert(__is_same(add_lvalue_reference_t<int (*)()>, int (*&)()), "");
3124 static_assert(__is_same(add_lvalue_reference_t<int (&)()>, int (&)()), "");
3126 static_assert(__is_same(add_lvalue_reference_t<S>, S &), "");
3127 static_assert(__is_same(add_lvalue_reference_t<const S>, const S &), "");
3128 static_assert(__is_same(add_lvalue_reference_t<volatile S>, volatile S &), "");
3129 static_assert(__is_same(add_lvalue_reference_t<const volatile S>, const volatile S &), "");
3130 static_assert(__is_same(add_lvalue_reference_t<int S::*>, int S::*&), "");
3131 static_assert(__is_same(add_lvalue_reference_t<int (S::*)()>, int(S::*&)()), "");
3134 template <class T> using add_rvalue_reference_t = __add_rvalue_reference(T);
3136 void add_rvalue_reference() {
3137 static_assert(__is_same(add_rvalue_reference_t<void>, void), "");
3138 static_assert(__is_same(add_rvalue_reference_t<const void>, const void), "");
3139 static_assert(__is_same(add_rvalue_reference_t<volatile void>, volatile void), "");
3140 static_assert(__is_same(add_rvalue_reference_t<const volatile void>, const volatile void), "");
3141 static_assert(__is_same(add_rvalue_reference_t<int>, int &&), "");
3142 static_assert(__is_same(add_rvalue_reference_t<const int>, const int &&), "");
3143 static_assert(__is_same(add_rvalue_reference_t<volatile int>, volatile int &&), "");
3144 static_assert(__is_same(add_rvalue_reference_t<const volatile int>, const volatile int &&), "");
3145 static_assert(__is_same(add_rvalue_reference_t<int *>, int *&&), "");
3146 static_assert(__is_same(add_rvalue_reference_t<int &>, int &), ""); // reference collapsing
3147 static_assert(__is_same(add_rvalue_reference_t<int &&>, int &&), "");
3148 static_assert(__is_same(add_rvalue_reference_t<int()>, int(&&)()), "");
3149 static_assert(__is_same(add_rvalue_reference_t<int (*)()>, int (*&&)()), "");
3150 static_assert(__is_same(add_rvalue_reference_t<int (&)()>, int (&)()), ""); // reference collapsing
3152 static_assert(__is_same(add_rvalue_reference_t<S>, S &&), "");
3153 static_assert(__is_same(add_rvalue_reference_t<const S>, const S &&), "");
3154 static_assert(__is_same(add_rvalue_reference_t<volatile S>, volatile S &&), "");
3155 static_assert(__is_same(add_rvalue_reference_t<const volatile S>, const volatile S &&), "");
3156 static_assert(__is_same(add_rvalue_reference_t<int S::*>, int S::*&&), "");
3157 static_assert(__is_same(add_rvalue_reference_t<int (S::*)()>, int(S::* &&)()), "");
3160 template <class T> using remove_reference_t = __remove_reference_t(T);
3162 void check_remove_reference() {
3163 static_assert(__is_same(remove_reference_t<void>, void), "");
3164 static_assert(__is_same(remove_reference_t<const volatile void>, const volatile void), "");
3165 static_assert(__is_same(remove_reference_t<int>, int), "");
3166 static_assert(__is_same(remove_reference_t<const int>, const int), "");
3167 static_assert(__is_same(remove_reference_t<volatile int>, volatile int), "");
3168 static_assert(__is_same(remove_reference_t<const volatile int>, const volatile int), "");
3169 static_assert(__is_same(remove_reference_t<int *>, int *), "");
3170 static_assert(__is_same(remove_reference_t<int *const volatile>, int *const volatile), "");
3171 static_assert(__is_same(remove_reference_t<int const *const volatile>, int const *const volatile), "");
3172 static_assert(__is_same(remove_reference_t<int &>, int), "");
3173 static_assert(__is_same(remove_reference_t<int const volatile &>, int const volatile), "");
3174 static_assert(__is_same(remove_reference_t<int &&>, int), "");
3175 static_assert(__is_same(remove_reference_t<int const volatile &&>, int const volatile), "");
3176 static_assert(__is_same(remove_reference_t<int()>, int()), "");
3177 static_assert(__is_same(remove_reference_t<int (*const volatile)()>, int (*const volatile)()), "");
3178 static_assert(__is_same(remove_reference_t<int (&)()>, int()), "");
3180 static_assert(__is_same(remove_reference_t<S>, S), "");
3181 static_assert(__is_same(remove_reference_t<S &>, S), "");
3182 static_assert(__is_same(remove_reference_t<S &&>, S), "");
3183 static_assert(__is_same(remove_reference_t<const S>, const S), "");
3184 static_assert(__is_same(remove_reference_t<const S &>, const S), "");
3185 static_assert(__is_same(remove_reference_t<const S &&>, const S), "");
3186 static_assert(__is_same(remove_reference_t<volatile S>, volatile S), "");
3187 static_assert(__is_same(remove_reference_t<volatile S &>, volatile S), "");
3188 static_assert(__is_same(remove_reference_t<volatile S &&>, volatile S), "");
3189 static_assert(__is_same(remove_reference_t<const volatile S>, const volatile S), "");
3190 static_assert(__is_same(remove_reference_t<const volatile S &>, const volatile S), "");
3191 static_assert(__is_same(remove_reference_t<const volatile S &&>, const volatile S), "");
3192 static_assert(__is_same(remove_reference_t<int S::*const volatile &>, int S::*const volatile), "");
3193 static_assert(__is_same(remove_reference_t<int (S::*const volatile &)()>, int(S::*const volatile)()), "");
3194 static_assert(__is_same(remove_reference_t<int (S::*const volatile &&)() &>, int(S::*const volatile)() &), "");
3197 template <class T> using remove_cvref_t = __remove_cvref(T);
3199 void check_remove_cvref() {
3200 static_assert(__is_same(remove_cvref_t<void>, void), "");
3201 static_assert(__is_same(remove_cvref_t<const volatile void>, void), "");
3202 static_assert(__is_same(remove_cvref_t<int>, int), "");
3203 static_assert(__is_same(remove_cvref_t<const int>, int), "");
3204 static_assert(__is_same(remove_cvref_t<volatile int>, int), "");
3205 static_assert(__is_same(remove_cvref_t<const volatile int>, int), "");
3206 static_assert(__is_same(remove_cvref_t<int *>, int *), "");
3207 static_assert(__is_same(remove_cvref_t<int *const volatile>, int *), "");
3208 static_assert(__is_same(remove_cvref_t<int const *const volatile>, int const *), "");
3209 static_assert(__is_same(remove_cvref_t<int const *const volatile __restrict>, int const *__restrict), "");
3210 static_assert(__is_same(remove_cvref_t<int const *const volatile _Nonnull>, int const *_Nonnull), "");
3211 static_assert(__is_same(remove_cvref_t<int &>, int), "");
3212 static_assert(__is_same(remove_cvref_t<int const volatile &>, int), "");
3213 static_assert(__is_same(remove_cvref_t<int &&>, int), "");
3214 static_assert(__is_same(remove_cvref_t<int const volatile &&>, int), "");
3215 static_assert(__is_same(remove_cvref_t<int()>, int()), "");
3216 static_assert(__is_same(remove_cvref_t<int (*const volatile)()>, int (*)()), "");
3217 static_assert(__is_same(remove_cvref_t<int (&)()>, int()), "");
3219 static_assert(__is_same(remove_cvref_t<S>, S), "");
3220 static_assert(__is_same(remove_cvref_t<S &>, S), "");
3221 static_assert(__is_same(remove_cvref_t<S &&>, S), "");
3222 static_assert(__is_same(remove_cvref_t<const S>, S), "");
3223 static_assert(__is_same(remove_cvref_t<const S &>, S), "");
3224 static_assert(__is_same(remove_cvref_t<const S &&>, S), "");
3225 static_assert(__is_same(remove_cvref_t<volatile S>, S), "");
3226 static_assert(__is_same(remove_cvref_t<volatile S &>, S), "");
3227 static_assert(__is_same(remove_cvref_t<volatile S &&>, S), "");
3228 static_assert(__is_same(remove_cvref_t<const volatile S>, S), "");
3229 static_assert(__is_same(remove_cvref_t<const volatile S &>, S), "");
3230 static_assert(__is_same(remove_cvref_t<const volatile S &&>, S), "");
3231 static_assert(__is_same(remove_cvref_t<int S::*const volatile>, int S::*), "");
3232 static_assert(__is_same(remove_cvref_t<int (S::*const volatile)()>, int(S::*)()), "");
3233 static_assert(__is_same(remove_cvref_t<int (S::*const volatile)() &>, int(S::*)() &), "");
3234 static_assert(__is_same(remove_cvref_t<int (S::*const volatile)() &&>, int(S::*)() &&), "");
3237 template <class T> using decay_t = __decay(T);
3238 template <class T> struct dne;
3240 void check_decay() {
3241 static_assert(__is_same(decay_t<void>, void), "");
3242 static_assert(__is_same(decay_t<const volatile void>, void), "");
3243 static_assert(__is_same(decay_t<int>, int), "");
3244 static_assert(__is_same(decay_t<const int>, int), "");
3245 static_assert(__is_same(decay_t<volatile int>, int), "");
3246 static_assert(__is_same(decay_t<const volatile int>, int), "");
3247 static_assert(__is_same(decay_t<int *>, int *), "");
3248 static_assert(__is_same(decay_t<int *const volatile>, int *), "");
3249 static_assert(__is_same(decay_t<int *const volatile __restrict>, int *), "");
3250 static_assert(__is_same(decay_t<int const *const volatile>, int const *), "");
3251 static_assert(__is_same(decay_t<int const *const volatile _Nonnull>, int const *), "");
3252 static_assert(__is_same(decay_t<int &>, int), "");
3253 static_assert(__is_same(decay_t<int const volatile &>, int), "");
3254 static_assert(__is_same(decay_t<int &&>, int), "");
3255 static_assert(__is_same(decay_t<int const volatile &&>, int), "");
3256 static_assert(__is_same(decay_t<int()>, int (*)()), "");
3257 static_assert(__is_same(decay_t<int (*)()>, int (*)()), "");
3258 static_assert(__is_same(decay_t<int (*const)()>, int (*)()), "");
3259 static_assert(__is_same(decay_t<int (*volatile)()>, int (*)()), "");
3260 static_assert(__is_same(decay_t<int (*const volatile)()>, int (*)()), "");
3261 static_assert(__is_same(decay_t<int (&)()>, int (*)()), "");
3262 static_assert(__is_same(decay_t<IntAr>, int *), "");
3263 static_assert(__is_same(decay_t<IntArNB>, int *), "");
3265 static_assert(__is_same(decay_t<S>, S), "");
3266 static_assert(__is_same(decay_t<S &>, S), "");
3267 static_assert(__is_same(decay_t<S &&>, S), "");
3268 static_assert(__is_same(decay_t<const S>, S), "");
3269 static_assert(__is_same(decay_t<const S &>, S), "");
3270 static_assert(__is_same(decay_t<const S &&>, S), "");
3271 static_assert(__is_same(decay_t<volatile S>, S), "");
3272 static_assert(__is_same(decay_t<volatile S &>, S), "");
3273 static_assert(__is_same(decay_t<volatile S &&>, S), "");
3274 static_assert(__is_same(decay_t<const volatile S>, S), "");
3275 static_assert(__is_same(decay_t<const volatile S &>, S), "");
3276 static_assert(__is_same(decay_t<const volatile S &&>, S), "");
3277 static_assert(__is_same(decay_t<int S::*const volatile>, int S::*), "");
3278 static_assert(__is_same(decay_t<int (S::*const volatile)()>, int(S::*)()), "");
3279 static_assert(__is_same(decay_t<int S::*const volatile &>, int S::*), "");
3280 static_assert(__is_same(decay_t<int (S::*const volatile &)()>, int(S::*)()), "");
3281 static_assert(__is_same(decay_t<int S::*const volatile &&>, int S::*), "");
3284 template <class T> struct CheckAbominableFunction {};
3285 template <class M>
3286 struct CheckAbominableFunction<M S::*> {
3287 static void checks() {
3288 static_assert(__is_same(add_lvalue_reference_t<M>, M), "");
3289 static_assert(__is_same(add_pointer_t<M>, M), "");
3290 static_assert(__is_same(add_rvalue_reference_t<M>, M), "");
3291 static_assert(__is_same(decay_t<M>, M), "");
3292 static_assert(__is_same(remove_const_t<M>, M), "");
3293 static_assert(__is_same(remove_volatile_t<M>, M), "");
3294 static_assert(__is_same(remove_cv_t<M>, M), "");
3295 static_assert(__is_same(remove_cvref_t<M>, M), "");
3296 static_assert(__is_same(remove_pointer_t<M>, M), "");
3297 static_assert(__is_same(remove_reference_t<M>, M), "");
3301 void check_abominable_function() {
3302 { CheckAbominableFunction<int (S::*)() &> x; }
3303 { CheckAbominableFunction<int (S::*)() &&> x; }
3304 { CheckAbominableFunction<int (S::*)() const> x; }
3305 { CheckAbominableFunction<int (S::*)() const &> x; }
3306 { CheckAbominableFunction<int (S::*)() const &&> x; }
3307 { CheckAbominableFunction<int (S::*)() volatile> x; }
3308 { CheckAbominableFunction<int (S::*)() volatile &> x; }
3309 { CheckAbominableFunction<int (S::*)() volatile &&> x; }
3310 { CheckAbominableFunction<int (S::*)() const volatile> x; }
3311 { CheckAbominableFunction<int (S::*)() const volatile &> x; }
3312 { CheckAbominableFunction<int (S::*)() const volatile &&> x; }
3315 template <class T> using make_signed_t = __make_signed(T);
3316 template <class T, class Expected>
3317 void check_make_signed() {
3318 static_assert(__is_same(make_signed_t<T>, Expected), "");
3319 static_assert(__is_same(make_signed_t<const T>, const Expected), "");
3320 static_assert(__is_same(make_signed_t<volatile T>, volatile Expected), "");
3321 static_assert(__is_same(make_signed_t<const volatile T>, const volatile Expected), "");
3324 #if defined(__ILP32__) || defined(__LLP64__)
3325 using Int64 = long long;
3326 using UInt64 = unsigned long long;
3327 #elif defined(__LP64__) || defined(__ILP64__) || defined(__SILP64__)
3328 using Int64 = long;
3329 using UInt64 = unsigned long;
3330 #else
3331 #error Programming model currently unsupported; please add a new entry.
3332 #endif
3334 enum UnscopedBool : bool {}; // deliberately char
3335 enum class ScopedBool : bool {}; // deliberately char
3336 enum UnscopedChar : char {}; // deliberately char
3337 enum class ScopedChar : char {}; // deliberately char
3338 enum UnscopedUChar : unsigned char {};
3339 enum class ScopedUChar : unsigned char {};
3340 enum UnscopedLongLong : long long {};
3341 enum UnscopedULongLong : unsigned long long {};
3342 enum class ScopedLongLong : long long {};
3343 enum class ScopedULongLong : unsigned long long {};
3344 enum class UnscopedInt128 : __int128 {};
3345 enum class ScopedInt128 : __int128 {};
3346 enum class UnscopedUInt128 : unsigned __int128 {};
3347 enum class ScopedUInt128 : unsigned __int128 {};
3348 enum UnscopedBit : unsigned _BitInt(1) {};
3349 enum ScopedBit : unsigned _BitInt(1) {};
3350 enum UnscopedIrregular : _BitInt(21) {};
3351 enum UnscopedUIrregular : unsigned _BitInt(21) {};
3352 enum class ScopedIrregular : _BitInt(21) {};
3353 enum class ScopedUIrregular : unsigned _BitInt(21) {};
3355 void make_signed() {
3356 check_make_signed<char, signed char>();
3357 check_make_signed<signed char, signed char>();
3358 check_make_signed<unsigned char, signed char>();
3359 check_make_signed<short, short>();
3360 check_make_signed<unsigned short, short>();
3361 check_make_signed<int, int>();
3362 check_make_signed<unsigned int, int>();
3363 check_make_signed<long, long>();
3364 check_make_signed<unsigned long, long>();
3365 check_make_signed<long long, long long>();
3366 check_make_signed<unsigned long long, long long>();
3367 check_make_signed<__int128, __int128>();
3368 check_make_signed<__uint128_t, __int128>();
3369 check_make_signed<_BitInt(65), _BitInt(65)>();
3370 check_make_signed<unsigned _BitInt(65), _BitInt(65)>();
3372 check_make_signed<wchar_t, int>();
3373 #if __cplusplus >= 202002L
3374 check_make_signed<char8_t, signed char>();
3375 #endif
3376 #if __cplusplus >= 201103L
3377 check_make_signed<char16_t, short>();
3378 check_make_signed<char32_t, int>();
3379 #endif
3381 check_make_signed<UnscopedChar, signed char>();
3382 check_make_signed<ScopedChar, signed char>();
3383 check_make_signed<UnscopedUChar, signed char>();
3384 check_make_signed<ScopedUChar, signed char>();
3386 check_make_signed<UnscopedLongLong, Int64>();
3387 check_make_signed<UnscopedULongLong, Int64>();
3388 check_make_signed<ScopedLongLong, Int64>();
3389 check_make_signed<ScopedULongLong, Int64>();
3391 check_make_signed<UnscopedInt128, __int128>();
3392 check_make_signed<ScopedInt128, __int128>();
3393 check_make_signed<UnscopedUInt128, __int128>();
3394 check_make_signed<ScopedUInt128, __int128>();
3396 check_make_signed<UnscopedIrregular, _BitInt(21)>();
3397 check_make_signed<UnscopedUIrregular, _BitInt(21)>();
3398 check_make_signed<ScopedIrregular, _BitInt(21)>();
3399 check_make_signed<ScopedUIrregular, _BitInt(21)>();
3401 { using ExpectedError = __make_signed(bool); }
3402 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'bool'}}
3403 { using ExpectedError = __make_signed(UnscopedBool); }
3404 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'UnscopedBool' whose underlying type is 'bool'}}
3405 { using ExpectedError = __make_signed(ScopedBool); }
3406 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'ScopedBool' whose underlying type is 'bool'}}
3407 { using ExpectedError = __make_signed(unsigned _BitInt(1)); }
3408 // expected-error@*:*{{'make_signed' is only compatible with non-_BitInt(1) integers and enum types, but was given 'unsigned _BitInt(1)'}}
3409 { using ExpectedError = __make_signed(UnscopedBit); }
3410 // expected-error@*:*{{'make_signed' is only compatible with non-_BitInt(1) integers and enum types, but was given 'UnscopedBit' whose underlying type is 'unsigned _BitInt(1)'}}
3411 { using ExpectedError = __make_signed(ScopedBit); }
3412 // expected-error@*:*{{'make_signed' is only compatible with non-_BitInt(1) integers and enum types, but was given 'ScopedBit' whose underlying type is 'unsigned _BitInt(1)'}}
3413 { using ExpectedError = __make_signed(int[]); }
3414 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int[]'}}
3415 { using ExpectedError = __make_signed(int[5]); }
3416 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int[5]'}}
3417 { using ExpectedError = __make_signed(void); }
3418 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'void'}}
3419 { using ExpectedError = __make_signed(int *); }
3420 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int *'}}
3421 { using ExpectedError = __make_signed(int &); }
3422 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int &'}}
3423 { using ExpectedError = __make_signed(int &&); }
3424 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int &&'}}
3425 { using ExpectedError = __make_signed(float); }
3426 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'float'}}
3427 { using ExpectedError = __make_signed(double); }
3428 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'double'}}
3429 { using ExpectedError = __make_signed(long double); }
3430 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'long double'}}
3431 { using ExpectedError = __make_signed(S); }
3432 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'S'}}
3433 { using ExpectedError = __make_signed(S *); }
3434 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'S *'}}
3435 { using ExpectedError = __make_signed(int S::*); }
3436 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int S::*'}}
3437 { using ExpectedError = __make_signed(int(S::*)()); }
3438 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int (S::*)()'}}
3441 template <class T>
3442 using make_unsigned_t = __make_unsigned(T);
3444 template <class T, class Expected>
3445 void check_make_unsigned() {
3446 static_assert(__is_same(make_unsigned_t<T>, Expected), "");
3447 static_assert(__is_same(make_unsigned_t<const T>, const Expected), "");
3448 static_assert(__is_same(make_unsigned_t<volatile T>, volatile Expected), "");
3449 static_assert(__is_same(make_unsigned_t<const volatile T>, const volatile Expected), "");
3452 void make_unsigned() {
3453 check_make_unsigned<char, unsigned char>();
3454 check_make_unsigned<signed char, unsigned char>();
3455 check_make_unsigned<unsigned char, unsigned char>();
3456 check_make_unsigned<short, unsigned short>();
3457 check_make_unsigned<unsigned short, unsigned short>();
3458 check_make_unsigned<int, unsigned int>();
3459 check_make_unsigned<unsigned int, unsigned int>();
3460 check_make_unsigned<long, unsigned long>();
3461 check_make_unsigned<unsigned long, unsigned long>();
3462 check_make_unsigned<long long, unsigned long long>();
3463 check_make_unsigned<unsigned long long, unsigned long long>();
3464 check_make_unsigned<__int128, __uint128_t>();
3465 check_make_unsigned<__uint128_t, __uint128_t>();
3466 check_make_unsigned<_BitInt(65), unsigned _BitInt(65)>();
3467 check_make_unsigned<unsigned _BitInt(65), unsigned _BitInt(65)>();
3469 check_make_unsigned<wchar_t, unsigned int>();
3470 #if __cplusplus >= 202002L
3471 check_make_unsigned<char8_t, unsigned char>();
3472 #endif
3473 #if __cplusplus >= 201103L
3474 check_make_unsigned<char16_t, unsigned short>();
3475 check_make_unsigned<char32_t, unsigned int>();
3476 #endif
3478 check_make_unsigned<UnscopedChar, unsigned char>();
3479 check_make_unsigned<ScopedChar, unsigned char>();
3480 check_make_unsigned<UnscopedUChar, unsigned char>();
3481 check_make_unsigned<ScopedUChar, unsigned char>();
3483 check_make_unsigned<UnscopedLongLong, UInt64>();
3484 check_make_unsigned<UnscopedULongLong, UInt64>();
3485 check_make_unsigned<ScopedLongLong, UInt64>();
3486 check_make_unsigned<ScopedULongLong, UInt64>();
3488 check_make_unsigned<UnscopedInt128, unsigned __int128>();
3489 check_make_unsigned<ScopedInt128, unsigned __int128>();
3490 check_make_unsigned<UnscopedUInt128, unsigned __int128>();
3491 check_make_unsigned<ScopedUInt128, unsigned __int128>();
3493 check_make_unsigned<UnscopedIrregular, unsigned _BitInt(21)>();
3494 check_make_unsigned<UnscopedUIrregular, unsigned _BitInt(21)>();
3495 check_make_unsigned<ScopedIrregular, unsigned _BitInt(21)>();
3496 check_make_unsigned<ScopedUIrregular, unsigned _BitInt(21)>();
3498 { using ExpectedError = __make_unsigned(bool); }
3499 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'bool'}}
3500 { using ExpectedError = __make_unsigned(UnscopedBool); }
3501 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'UnscopedBool' whose underlying type is 'bool'}}
3502 { using ExpectedError = __make_unsigned(ScopedBool); }
3503 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'ScopedBool' whose underlying type is 'bool'}}
3504 { using ExpectedError = __make_unsigned(unsigned _BitInt(1)); }
3505 // expected-error@*:*{{'make_unsigned' is only compatible with non-_BitInt(1) integers and enum types, but was given 'unsigned _BitInt(1)'}}
3506 { using ExpectedError = __make_unsigned(UnscopedBit); }
3507 // expected-error@*:*{{'make_unsigned' is only compatible with non-_BitInt(1) integers and enum types, but was given 'UnscopedBit'}}
3508 { using ExpectedError = __make_unsigned(ScopedBit); }
3509 // expected-error@*:*{{'make_unsigned' is only compatible with non-_BitInt(1) integers and enum types, but was given 'ScopedBit'}}
3510 { using ExpectedError = __make_unsigned(int[]); }
3511 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int[]'}}
3512 { using ExpectedError = __make_unsigned(int[5]); }
3513 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int[5]'}}
3514 { using ExpectedError = __make_unsigned(void); }
3515 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'void'}}
3516 { using ExpectedError = __make_unsigned(int *); }
3517 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int *'}}
3518 { using ExpectedError = __make_unsigned(int &); }
3519 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int &'}}
3520 { using ExpectedError = __make_unsigned(int &&); }
3521 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int &&'}}
3522 { using ExpectedError = __make_unsigned(float); }
3523 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'float'}}
3524 { using ExpectedError = __make_unsigned(double); }
3525 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'double'}}
3526 { using ExpectedError = __make_unsigned(long double); }
3527 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'long double'}}
3528 { using ExpectedError = __make_unsigned(S); }
3529 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'S'}}
3530 { using ExpectedError = __make_unsigned(S *); }
3531 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'S *'}}
3532 { using ExpectedError = __make_unsigned(int S::*); }
3533 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int S::*'}}
3534 { using ExpectedError = __make_unsigned(int(S::*)()); }
3535 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int (S::*)()'}}
3538 template <class T> using remove_extent_t = __remove_extent(T);
3540 void remove_extent() {
3541 static_assert(__is_same(remove_extent_t<void>, void), "");
3542 static_assert(__is_same(remove_extent_t<int>, int), "");
3543 static_assert(__is_same(remove_extent_t<int[]>, int), "");
3544 static_assert(__is_same(remove_extent_t<int[1]>, int), "");
3545 static_assert(__is_same(remove_extent_t<int[1][2]>, int[2]), "");
3546 static_assert(__is_same(remove_extent_t<int[][2]>, int[2]), "");
3547 static_assert(__is_same(remove_extent_t<const int[]>, const int), "");
3548 static_assert(__is_same(remove_extent_t<const int[1]>, const int), "");
3549 static_assert(__is_same(remove_extent_t<const int[1][2]>, const int[2]), "");
3550 static_assert(__is_same(remove_extent_t<const int[][2]>, const int[2]), "");
3551 static_assert(__is_same(remove_extent_t<volatile int[]>, volatile int), "");
3552 static_assert(__is_same(remove_extent_t<volatile int[1]>, volatile int), "");
3553 static_assert(__is_same(remove_extent_t<volatile int[1][2]>, volatile int[2]), "");
3554 static_assert(__is_same(remove_extent_t<volatile int[][2]>, volatile int[2]), "");
3555 static_assert(__is_same(remove_extent_t<const volatile int[]>, const volatile int), "");
3556 static_assert(__is_same(remove_extent_t<const volatile int[1]>, const volatile int), "");
3557 static_assert(__is_same(remove_extent_t<const volatile int[1][2]>, const volatile int[2]), "");
3558 static_assert(__is_same(remove_extent_t<const volatile int[][2]>, const volatile int[2]), "");
3559 static_assert(__is_same(remove_extent_t<int *>, int *), "");
3560 static_assert(__is_same(remove_extent_t<int &>, int &), "");
3561 static_assert(__is_same(remove_extent_t<int &&>, int &&), "");
3562 static_assert(__is_same(remove_extent_t<int()>, int()), "");
3563 static_assert(__is_same(remove_extent_t<int (*)()>, int (*)()), "");
3564 static_assert(__is_same(remove_extent_t<int (&)()>, int (&)()), "");
3566 static_assert(__is_same(remove_extent_t<S>, S), "");
3567 static_assert(__is_same(remove_extent_t<int S::*>, int S::*), "");
3568 static_assert(__is_same(remove_extent_t<int (S::*)()>, int(S::*)()), "");
3570 using SomeArray = int[1][2];
3571 static_assert(__is_same(remove_extent_t<const SomeArray>, const int[2]), "");
3574 template <class T> using remove_all_extents_t = __remove_all_extents(T);
3576 void remove_all_extents() {
3577 static_assert(__is_same(remove_all_extents_t<void>, void), "");
3578 static_assert(__is_same(remove_all_extents_t<int>, int), "");
3579 static_assert(__is_same(remove_all_extents_t<const int>, const int), "");
3580 static_assert(__is_same(remove_all_extents_t<volatile int>, volatile int), "");
3581 static_assert(__is_same(remove_all_extents_t<const volatile int>, const volatile int), "");
3582 static_assert(__is_same(remove_all_extents_t<int[]>, int), "");
3583 static_assert(__is_same(remove_all_extents_t<int[1]>, int), "");
3584 static_assert(__is_same(remove_all_extents_t<int[1][2]>, int), "");
3585 static_assert(__is_same(remove_all_extents_t<int[][2]>, int), "");
3586 static_assert(__is_same(remove_all_extents_t<const int[]>, const int), "");
3587 static_assert(__is_same(remove_all_extents_t<const int[1]>, const int), "");
3588 static_assert(__is_same(remove_all_extents_t<const int[1][2]>, const int), "");
3589 static_assert(__is_same(remove_all_extents_t<const int[][2]>, const int), "");
3590 static_assert(__is_same(remove_all_extents_t<volatile int[]>, volatile int), "");
3591 static_assert(__is_same(remove_all_extents_t<volatile int[1]>, volatile int), "");
3592 static_assert(__is_same(remove_all_extents_t<volatile int[1][2]>, volatile int), "");
3593 static_assert(__is_same(remove_all_extents_t<volatile int[][2]>, volatile int), "");
3594 static_assert(__is_same(remove_all_extents_t<const volatile int[]>, const volatile int), "");
3595 static_assert(__is_same(remove_all_extents_t<const volatile int[1]>, const volatile int), "");
3596 static_assert(__is_same(remove_all_extents_t<const volatile int[1][2]>, const volatile int), "");
3597 static_assert(__is_same(remove_all_extents_t<const volatile int[][2]>, const volatile int), "");
3598 static_assert(__is_same(remove_all_extents_t<int *>, int *), "");
3599 static_assert(__is_same(remove_all_extents_t<int &>, int &), "");
3600 static_assert(__is_same(remove_all_extents_t<int &&>, int &&), "");
3601 static_assert(__is_same(remove_all_extents_t<int()>, int()), "");
3602 static_assert(__is_same(remove_all_extents_t<int (*)()>, int (*)()), "");
3603 static_assert(__is_same(remove_all_extents_t<int (&)()>, int (&)()), "");
3605 static_assert(__is_same(remove_all_extents_t<S>, S), "");
3606 static_assert(__is_same(remove_all_extents_t<int S::*>, int S::*), "");
3607 static_assert(__is_same(remove_all_extents_t<int (S::*)()>, int(S::*)()), "");
3609 using SomeArray = int[1][2];
3610 static_assert(__is_same(remove_all_extents_t<const SomeArray>, const int), "");