1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fblocks -Wno-deprecated-builtins -Wno-defaulted-function-deleted %s
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fblocks -Wno-deprecated-builtins -Wno-defaulted-function-deleted %s
3 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++17 -fblocks -Wno-deprecated-builtins -Wno-defaulted-function-deleted %s
4 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++20 -fblocks -Wno-deprecated-builtins -Wno-defaulted-function-deleted %s
6 #define T(b) (b) ? 1 : -1
7 #define F(b) (b) ? -1 : 1
9 struct NonPOD
{ NonPOD(int); };
10 typedef NonPOD NonPODAr
[10];
11 typedef NonPOD NonPODArNB
[];
12 typedef NonPOD NonPODArMB
[10][2];
16 enum SignedEnum
: signed int { };
17 enum UnsignedEnum
: unsigned int { };
18 enum class EnumClass
{ EV
};
19 enum class SignedEnumClass
: signed int {};
20 enum class UnsignedEnumClass
: unsigned int {};
21 struct POD
{ Enum e
; int i
; float f
; NonPOD
* p
; };
23 struct IncompleteStruct
;
24 typedef Empty EmptyAr
[10];
25 typedef Empty EmptyArNB
[];
26 typedef Empty EmptyArMB
[1][2];
28 typedef Int IntAr
[10];
29 typedef Int IntArNB
[];
30 class Statics
{ static int priv
; static NonPOD np
; };
32 union IncompleteUnion
; // expected-note {{forward declaration of 'IncompleteUnion'}}
33 union Union
{ int i
; float f
; };
34 struct HasFunc
{ void f (); };
35 struct HasOp
{ void operator *(); };
36 struct HasConv
{ operator int(); };
37 struct HasAssign
{ void operator =(int); };
39 struct HasAnonymousUnion
{
46 typedef int Vector
__attribute__((vector_size(16)));
47 typedef int VectorExt
__attribute__((ext_vector_type(4)));
49 using ComplexFloat
= _Complex
float;
50 using ComplexInt
= _Complex
int;
53 typedef const void cvoid
;
54 struct Derives
: POD
{};
55 typedef Derives DerivesAr
[10];
56 typedef Derives DerivesArNB
[];
57 struct DerivesEmpty
: Empty
{};
58 struct HasCons
{ HasCons(int); };
59 struct HasDefaultCons
{ HasDefaultCons() = default; };
60 struct HasExplicitDefaultCons
{ explicit HasExplicitDefaultCons() = default; };
61 struct HasInheritedCons
: HasDefaultCons
{ using HasDefaultCons::HasDefaultCons
; };
62 struct HasNoInheritedCons
: HasCons
{};
63 struct HasCopyAssign
{ HasCopyAssign
operator =(const HasCopyAssign
&); };
64 struct HasMoveAssign
{ HasMoveAssign
operator =(const HasMoveAssign
&&); };
65 struct HasNoThrowMoveAssign
{
66 HasNoThrowMoveAssign
& operator=(
67 const HasNoThrowMoveAssign
&&) throw(); };
68 struct HasNoExceptNoThrowMoveAssign
{
69 HasNoExceptNoThrowMoveAssign
& operator=(
70 const HasNoExceptNoThrowMoveAssign
&&) noexcept
;
72 struct HasThrowMoveAssign
{
73 HasThrowMoveAssign
& operator=(const HasThrowMoveAssign
&&)
74 #if __cplusplus <= 201402L
82 struct HasNoExceptFalseMoveAssign
{
83 HasNoExceptFalseMoveAssign
& operator=(
84 const HasNoExceptFalseMoveAssign
&&) noexcept(false); };
85 struct HasMoveCtor
{ HasMoveCtor(const HasMoveCtor
&&); };
86 struct HasMemberMoveCtor
{ HasMoveCtor member
; };
87 struct HasMemberMoveAssign
{ HasMoveAssign member
; };
88 struct HasStaticMemberMoveCtor
{ static HasMoveCtor member
; };
89 struct HasStaticMemberMoveAssign
{ static HasMoveAssign member
; };
90 struct HasMemberThrowMoveAssign
{ HasThrowMoveAssign member
; };
91 struct HasMemberNoExceptFalseMoveAssign
{
92 HasNoExceptFalseMoveAssign member
; };
93 struct HasMemberNoThrowMoveAssign
{ HasNoThrowMoveAssign member
; };
94 struct HasMemberNoExceptNoThrowMoveAssign
{
95 HasNoExceptNoThrowMoveAssign member
; };
97 struct HasDefaultTrivialCopyAssign
{
98 HasDefaultTrivialCopyAssign
&operator=(
99 const HasDefaultTrivialCopyAssign
&) = default;
101 struct TrivialMoveButNotCopy
{
102 TrivialMoveButNotCopy
&operator=(TrivialMoveButNotCopy
&&) = default;
103 TrivialMoveButNotCopy
&operator=(const TrivialMoveButNotCopy
&);
105 struct NonTrivialDefault
{
109 struct HasDest
{ ~HasDest(); };
110 class HasPriv
{ int priv
; };
111 class HasProt
{ protected: int prot
; };
112 struct HasRef
{ int i
; int& ref
; HasRef() : i(0), ref(i
) {} };
113 struct HasRefAggregate
{ int i
; int& ref
; };
114 struct HasNonPOD
{ NonPOD np
; };
115 struct HasVirt
{ virtual void Virt() {}; };
116 typedef NonPOD NonPODAr
[10];
117 typedef HasVirt VirtAr
[10];
118 typedef NonPOD NonPODArNB
[];
119 union NonPODUnion
{ int i
; Derives n
; };
120 struct DerivesHasCons
: HasCons
{};
121 struct DerivesHasCopyAssign
: HasCopyAssign
{};
122 struct DerivesHasMoveAssign
: HasMoveAssign
{};
123 struct DerivesHasDest
: HasDest
{};
124 struct DerivesHasPriv
: HasPriv
{};
125 struct DerivesHasProt
: HasProt
{};
126 struct DerivesHasRef
: HasRef
{};
127 struct DerivesHasVirt
: HasVirt
{};
128 struct DerivesHasMoveCtor
: HasMoveCtor
{};
130 struct HasNoThrowCopyAssign
{
131 void operator =(const HasNoThrowCopyAssign
&) throw();
133 struct HasMultipleCopyAssign
{
134 void operator =(const HasMultipleCopyAssign
&) throw();
135 void operator =(volatile HasMultipleCopyAssign
&);
137 struct HasMultipleNoThrowCopyAssign
{
138 void operator =(const HasMultipleNoThrowCopyAssign
&) throw();
139 void operator =(volatile HasMultipleNoThrowCopyAssign
&) throw();
142 struct HasNoThrowConstructor
{ HasNoThrowConstructor() throw(); };
143 struct HasNoThrowConstructorWithArgs
{
144 HasNoThrowConstructorWithArgs(HasCons i
= HasCons(0)) throw();
146 struct HasMultipleDefaultConstructor1
{
147 HasMultipleDefaultConstructor1() throw();
148 HasMultipleDefaultConstructor1(int i
= 0);
150 struct HasMultipleDefaultConstructor2
{
151 HasMultipleDefaultConstructor2(int i
= 0);
152 HasMultipleDefaultConstructor2() throw();
155 struct HasNoThrowCopy
{ HasNoThrowCopy(const HasNoThrowCopy
&) throw(); };
156 struct HasMultipleCopy
{
157 HasMultipleCopy(const HasMultipleCopy
&) throw();
158 HasMultipleCopy(volatile HasMultipleCopy
&);
160 struct HasMultipleNoThrowCopy
{
161 HasMultipleNoThrowCopy(const HasMultipleNoThrowCopy
&) throw();
162 HasMultipleNoThrowCopy(volatile HasMultipleNoThrowCopy
&) throw();
165 struct HasVirtDest
{ virtual ~HasVirtDest(); };
166 struct DerivedVirtDest
: HasVirtDest
{};
167 typedef HasVirtDest VirtDestAr
[1];
170 AllPrivate() throw();
171 AllPrivate(const AllPrivate
&) throw();
172 AllPrivate
&operator=(const AllPrivate
&) throw();
173 ~AllPrivate() throw();
176 struct ThreeArgCtor
{
177 ThreeArgCtor(int*, char*, int);
180 struct VariadicCtor
{
181 template<typename
...T
> VariadicCtor(T
...);
184 struct ThrowingDtor
{
186 #if __cplusplus <= 201402L
193 struct NoExceptDtor
{
194 ~NoExceptDtor() noexcept(true);
198 ~NoThrowDtor() throw();
201 struct ACompleteType
{};
202 struct AnIncompleteType
; // expected-note 1+ {{forward declaration of 'AnIncompleteType'}}
203 typedef AnIncompleteType AnIncompleteTypeAr
[42];
204 typedef AnIncompleteType AnIncompleteTypeArNB
[];
205 typedef AnIncompleteType AnIncompleteTypeArMB
[1][10];
207 struct HasInClassInit
{
211 struct HasPrivateBase
: private ACompleteType
{};
212 struct HasProtectedBase
: protected ACompleteType
{};
213 struct HasVirtBase
: virtual ACompleteType
{};
217 { int arr
[T(__is_pod(int))]; }
218 { int arr
[T(__is_pod(Enum
))]; }
219 { int arr
[T(__is_pod(POD
))]; }
220 { int arr
[T(__is_pod(Int
))]; }
221 { int arr
[T(__is_pod(IntAr
))]; }
222 { int arr
[T(__is_pod(Statics
))]; }
223 { int arr
[T(__is_pod(Empty
))]; }
224 { int arr
[T(__is_pod(EmptyUnion
))]; }
225 { int arr
[T(__is_pod(Union
))]; }
226 { int arr
[T(__is_pod(HasFunc
))]; }
227 { int arr
[T(__is_pod(HasOp
))]; }
228 { int arr
[T(__is_pod(HasConv
))]; }
229 { int arr
[T(__is_pod(HasAssign
))]; }
230 { int arr
[T(__is_pod(IntArNB
))]; }
231 { int arr
[T(__is_pod(HasAnonymousUnion
))]; }
232 { int arr
[T(__is_pod(Vector
))]; }
233 { int arr
[T(__is_pod(VectorExt
))]; }
234 { int arr
[T(__is_pod(Derives
))]; }
235 { int arr
[T(__is_pod(DerivesAr
))]; }
236 { int arr
[T(__is_pod(DerivesArNB
))]; }
237 { int arr
[T(__is_pod(DerivesEmpty
))]; }
238 { int arr
[T(__is_pod(HasPriv
))]; }
239 { int arr
[T(__is_pod(HasProt
))]; }
240 { int arr
[T(__is_pod(DerivesHasPriv
))]; }
241 { int arr
[T(__is_pod(DerivesHasProt
))]; }
243 { int arr
[F(__is_pod(HasCons
))]; }
244 { int arr
[F(__is_pod(HasCopyAssign
))]; }
245 { int arr
[F(__is_pod(HasMoveAssign
))]; }
246 { int arr
[F(__is_pod(HasDest
))]; }
247 { int arr
[F(__is_pod(HasRef
))]; }
248 { int arr
[F(__is_pod(HasVirt
))]; }
249 { int arr
[F(__is_pod(DerivesHasCons
))]; }
250 { int arr
[F(__is_pod(DerivesHasCopyAssign
))]; }
251 { int arr
[F(__is_pod(DerivesHasMoveAssign
))]; }
252 { int arr
[F(__is_pod(DerivesHasDest
))]; }
253 { int arr
[F(__is_pod(DerivesHasRef
))]; }
254 { int arr
[F(__is_pod(DerivesHasVirt
))]; }
255 { int arr
[F(__is_pod(NonPOD
))]; }
256 { int arr
[F(__is_pod(HasNonPOD
))]; }
257 { int arr
[F(__is_pod(NonPODAr
))]; }
258 { int arr
[F(__is_pod(NonPODArNB
))]; }
259 { int arr
[F(__is_pod(void))]; }
260 { int arr
[F(__is_pod(cvoid
))]; }
261 // { int arr[F(__is_pod(NonPODUnion))]; }
263 { int arr
[T(__is_pod(ACompleteType
))]; }
264 { int arr
[F(__is_pod(AnIncompleteType
))]; } // expected-error {{incomplete type}}
265 { int arr
[F(__is_pod(AnIncompleteType
[]))]; } // expected-error {{incomplete type}}
266 { int arr
[F(__is_pod(AnIncompleteType
[1]))]; } // expected-error {{incomplete type}}
269 typedef Empty EmptyAr
[10];
270 struct Bit0
{ int : 0; };
271 struct Bit0Cons
{ int : 0; Bit0Cons(); };
272 struct AnonBitOnly
{ int : 3; };
273 struct BitOnly
{ int x
: 3; };
274 struct DerivesVirt
: virtual POD
{};
278 { int arr
[T(__is_empty(Empty
))]; }
279 { int arr
[T(__is_empty(DerivesEmpty
))]; }
280 { int arr
[T(__is_empty(HasCons
))]; }
281 { int arr
[T(__is_empty(HasCopyAssign
))]; }
282 { int arr
[T(__is_empty(HasMoveAssign
))]; }
283 { int arr
[T(__is_empty(HasDest
))]; }
284 { int arr
[T(__is_empty(HasFunc
))]; }
285 { int arr
[T(__is_empty(HasOp
))]; }
286 { int arr
[T(__is_empty(HasConv
))]; }
287 { int arr
[T(__is_empty(HasAssign
))]; }
288 { int arr
[T(__is_empty(Bit0
))]; }
289 { int arr
[T(__is_empty(Bit0Cons
))]; }
291 { int arr
[F(__is_empty(Int
))]; }
292 { int arr
[F(__is_empty(POD
))]; }
293 { int arr
[F(__is_empty(EmptyUnion
))]; }
294 { int arr
[F(__is_empty(IncompleteUnion
))]; }
295 { int arr
[F(__is_empty(EmptyAr
))]; }
296 { int arr
[F(__is_empty(HasRef
))]; }
297 { int arr
[F(__is_empty(HasVirt
))]; }
298 { int arr
[F(__is_empty(AnonBitOnly
))]; }
299 { int arr
[F(__is_empty(BitOnly
))]; }
300 { int arr
[F(__is_empty(void))]; }
301 { int arr
[F(__is_empty(IntArNB
))]; }
302 { int arr
[F(__is_empty(HasAnonymousUnion
))]; }
303 // { int arr[F(__is_empty(DerivesVirt))]; }
305 { int arr
[T(__is_empty(ACompleteType
))]; }
306 { int arr
[F(__is_empty(AnIncompleteType
))]; } // expected-error {{incomplete type}}
307 { int arr
[F(__is_empty(AnIncompleteType
[]))]; }
308 { int arr
[F(__is_empty(AnIncompleteType
[1]))]; }
311 typedef Derives ClassType
;
315 { int arr
[T(__is_class(Derives
))]; }
316 { int arr
[T(__is_class(HasPriv
))]; }
317 { int arr
[T(__is_class(ClassType
))]; }
318 { int arr
[T(__is_class(HasAnonymousUnion
))]; }
320 { int arr
[F(__is_class(int))]; }
321 { int arr
[F(__is_class(Enum
))]; }
322 { int arr
[F(__is_class(Int
))]; }
323 { int arr
[F(__is_class(IntAr
))]; }
324 { int arr
[F(__is_class(DerivesAr
))]; }
325 { int arr
[F(__is_class(Union
))]; }
326 { int arr
[F(__is_class(cvoid
))]; }
327 { int arr
[F(__is_class(IntArNB
))]; }
330 typedef Union UnionAr
[10];
331 typedef Union UnionType
;
335 { int arr
[T(__is_union(Union
))]; }
336 { int arr
[T(__is_union(UnionType
))]; }
338 { int arr
[F(__is_union(int))]; }
339 { int arr
[F(__is_union(Enum
))]; }
340 { int arr
[F(__is_union(Int
))]; }
341 { int arr
[F(__is_union(IntAr
))]; }
342 { int arr
[F(__is_union(UnionAr
))]; }
343 { int arr
[F(__is_union(cvoid
))]; }
344 { int arr
[F(__is_union(IntArNB
))]; }
345 { int arr
[F(__is_union(HasAnonymousUnion
))]; }
348 typedef Enum EnumType
;
349 typedef EnumClass EnumClassType
;
353 { int arr
[T(__is_enum(Enum
))]; }
354 { int arr
[T(__is_enum(EnumType
))]; }
355 { int arr
[T(__is_enum(SignedEnum
))]; }
356 { int arr
[T(__is_enum(UnsignedEnum
))]; }
358 { int arr
[T(__is_enum(EnumClass
))]; }
359 { int arr
[T(__is_enum(EnumClassType
))]; }
360 { int arr
[T(__is_enum(SignedEnumClass
))]; }
361 { int arr
[T(__is_enum(UnsignedEnumClass
))]; }
363 { int arr
[F(__is_enum(int))]; }
364 { int arr
[F(__is_enum(Union
))]; }
365 { int arr
[F(__is_enum(Int
))]; }
366 { int arr
[F(__is_enum(IntAr
))]; }
367 { int arr
[F(__is_enum(UnionAr
))]; }
368 { int arr
[F(__is_enum(Derives
))]; }
369 { int arr
[F(__is_enum(ClassType
))]; }
370 { int arr
[F(__is_enum(cvoid
))]; }
371 { int arr
[F(__is_enum(IntArNB
))]; }
372 { int arr
[F(__is_enum(HasAnonymousUnion
))]; }
373 { int arr
[F(__is_enum(AnIncompleteType
))]; }
374 { int arr
[F(__is_enum(AnIncompleteTypeAr
))]; }
375 { int arr
[F(__is_enum(AnIncompleteTypeArMB
))]; }
376 { int arr
[F(__is_enum(AnIncompleteTypeArNB
))]; }
379 void is_scoped_enum() {
380 static_assert(!__is_scoped_enum(Enum
), "");
381 static_assert(!__is_scoped_enum(EnumType
), "");
382 static_assert(!__is_scoped_enum(SignedEnum
), "");
383 static_assert(!__is_scoped_enum(UnsignedEnum
), "");
385 static_assert(__is_scoped_enum(EnumClass
), "");
386 static_assert(__is_scoped_enum(EnumClassType
), "");
387 static_assert(__is_scoped_enum(SignedEnumClass
), "");
388 static_assert(__is_scoped_enum(UnsignedEnumClass
), "");
390 static_assert(!__is_scoped_enum(int), "");
391 static_assert(!__is_scoped_enum(Union
), "");
392 static_assert(!__is_scoped_enum(Int
), "");
393 static_assert(!__is_scoped_enum(IntAr
), "");
394 static_assert(!__is_scoped_enum(UnionAr
), "");
395 static_assert(!__is_scoped_enum(Derives
), "");
396 static_assert(!__is_scoped_enum(ClassType
), "");
397 static_assert(!__is_scoped_enum(cvoid
), "");
398 static_assert(!__is_scoped_enum(IntArNB
), "");
399 static_assert(!__is_scoped_enum(HasAnonymousUnion
), "");
400 static_assert(!__is_scoped_enum(AnIncompleteType
), "");
401 static_assert(!__is_scoped_enum(AnIncompleteTypeAr
), "");
402 static_assert(!__is_scoped_enum(AnIncompleteTypeArMB
), "");
403 static_assert(!__is_scoped_enum(AnIncompleteTypeArNB
), "");
406 struct FinalClass final
{
410 struct PotentiallyFinal
{ };
413 struct PotentiallyFinal
<T
*> final
{ };
416 struct PotentiallyFinal
<int> final
{ };
424 { int arr
[T(__is_final(FinalClass
))]; }
425 { int arr
[T(__is_final(PotentiallyFinal
<float*>))]; }
426 { int arr
[T(__is_final(PotentiallyFinal
<int>))]; }
428 { int arr
[F(__is_final(int))]; }
429 { int arr
[F(__is_final(Union
))]; }
430 { int arr
[F(__is_final(Int
))]; }
431 { int arr
[F(__is_final(IntAr
))]; }
432 { int arr
[F(__is_final(UnionAr
))]; }
433 { int arr
[F(__is_final(Derives
))]; }
434 { int arr
[F(__is_final(ClassType
))]; }
435 { int arr
[F(__is_final(cvoid
))]; }
436 { int arr
[F(__is_final(IntArNB
))]; }
437 { int arr
[F(__is_final(HasAnonymousUnion
))]; }
441 typedef HasVirt Polymorph
;
442 struct InheritPolymorph
: Polymorph
{};
444 void is_polymorphic()
446 { int arr
[T(__is_polymorphic(Polymorph
))]; }
447 { int arr
[T(__is_polymorphic(InheritPolymorph
))]; }
449 { int arr
[F(__is_polymorphic(int))]; }
450 { int arr
[F(__is_polymorphic(Union
))]; }
451 { int arr
[F(__is_polymorphic(IncompleteUnion
))]; }
452 { int arr
[F(__is_polymorphic(Int
))]; }
453 { int arr
[F(__is_polymorphic(IntAr
))]; }
454 { int arr
[F(__is_polymorphic(UnionAr
))]; }
455 { int arr
[F(__is_polymorphic(Derives
))]; }
456 { int arr
[F(__is_polymorphic(ClassType
))]; }
457 { int arr
[F(__is_polymorphic(Enum
))]; }
458 { int arr
[F(__is_polymorphic(cvoid
))]; }
459 { int arr
[F(__is_polymorphic(IntArNB
))]; }
464 int t01
[T(__is_integral(bool))];
465 int t02
[T(__is_integral(char))];
466 int t03
[T(__is_integral(signed char))];
467 int t04
[T(__is_integral(unsigned char))];
468 //int t05[T(__is_integral(char16_t))];
469 //int t06[T(__is_integral(char32_t))];
470 int t07
[T(__is_integral(wchar_t))];
471 int t08
[T(__is_integral(short))];
472 int t09
[T(__is_integral(unsigned short))];
473 int t10
[T(__is_integral(int))];
474 int t11
[T(__is_integral(unsigned int))];
475 int t12
[T(__is_integral(long))];
476 int t13
[T(__is_integral(unsigned long))];
478 int t21
[F(__is_integral(float))];
479 int t22
[F(__is_integral(double))];
480 int t23
[F(__is_integral(long double))];
481 int t24
[F(__is_integral(Union
))];
482 int t25
[F(__is_integral(UnionAr
))];
483 int t26
[F(__is_integral(Derives
))];
484 int t27
[F(__is_integral(ClassType
))];
485 int t28
[F(__is_integral(Enum
))];
486 int t29
[F(__is_integral(void))];
487 int t30
[F(__is_integral(cvoid
))];
488 int t31
[F(__is_integral(IntArNB
))];
491 void is_floating_point()
493 int t01
[T(__is_floating_point(float))];
494 int t02
[T(__is_floating_point(double))];
495 int t03
[T(__is_floating_point(long double))];
497 int t11
[F(__is_floating_point(bool))];
498 int t12
[F(__is_floating_point(char))];
499 int t13
[F(__is_floating_point(signed char))];
500 int t14
[F(__is_floating_point(unsigned char))];
501 //int t15[F(__is_floating_point(char16_t))];
502 //int t16[F(__is_floating_point(char32_t))];
503 int t17
[F(__is_floating_point(wchar_t))];
504 int t18
[F(__is_floating_point(short))];
505 int t19
[F(__is_floating_point(unsigned short))];
506 int t20
[F(__is_floating_point(int))];
507 int t21
[F(__is_floating_point(unsigned int))];
508 int t22
[F(__is_floating_point(long))];
509 int t23
[F(__is_floating_point(unsigned long))];
510 int t24
[F(__is_floating_point(Union
))];
511 int t25
[F(__is_floating_point(UnionAr
))];
512 int t26
[F(__is_floating_point(Derives
))];
513 int t27
[F(__is_floating_point(ClassType
))];
514 int t28
[F(__is_floating_point(Enum
))];
515 int t29
[F(__is_floating_point(void))];
516 int t30
[F(__is_floating_point(cvoid
))];
517 int t31
[F(__is_floating_point(IntArNB
))];
521 struct AggregateTemplate
{
526 struct NonAggregateTemplate
{
528 NonAggregateTemplate();
533 constexpr bool TrueAfterCpp11
= __cplusplus
> 201103L;
534 constexpr bool TrueAfterCpp14
= __cplusplus
> 201402L;
536 __is_aggregate(AnIncompleteType
); // expected-error {{incomplete type}}
537 __is_aggregate(IncompleteUnion
); // expected-error {{incomplete type}}
539 // Valid since LWG3823
540 static_assert(__is_aggregate(AnIncompleteType
[]), "");
541 static_assert(__is_aggregate(AnIncompleteType
[1]), "");
542 static_assert(__is_aggregate(AnIncompleteTypeAr
), "");
543 static_assert(__is_aggregate(AnIncompleteTypeArNB
), "");
544 static_assert(__is_aggregate(AnIncompleteTypeArMB
), "");
546 static_assert(!__is_aggregate(NonPOD
), "");
547 static_assert(__is_aggregate(NonPODAr
), "");
548 static_assert(__is_aggregate(NonPODArNB
), "");
549 static_assert(__is_aggregate(NonPODArMB
), "");
551 static_assert(!__is_aggregate(Enum
), "");
552 static_assert(__is_aggregate(POD
), "");
553 static_assert(__is_aggregate(Empty
), "");
554 static_assert(__is_aggregate(EmptyAr
), "");
555 static_assert(__is_aggregate(EmptyArNB
), "");
556 static_assert(__is_aggregate(EmptyArMB
), "");
557 static_assert(!__is_aggregate(void), "");
558 static_assert(!__is_aggregate(const volatile void), "");
559 static_assert(!__is_aggregate(int), "");
560 static_assert(__is_aggregate(IntAr
), "");
561 static_assert(__is_aggregate(IntArNB
), "");
562 static_assert(__is_aggregate(EmptyUnion
), "");
563 static_assert(__is_aggregate(Union
), "");
564 static_assert(__is_aggregate(Statics
), "");
565 static_assert(__is_aggregate(HasFunc
), "");
566 static_assert(__is_aggregate(HasOp
), "");
567 static_assert(__is_aggregate(HasAssign
), "");
568 static_assert(__is_aggregate(HasAnonymousUnion
), "");
570 static_assert(__is_aggregate(Derives
) == TrueAfterCpp14
, "");
571 static_assert(__is_aggregate(DerivesAr
), "");
572 static_assert(__is_aggregate(DerivesArNB
), "");
573 static_assert(!__is_aggregate(HasCons
), "");
574 #if __cplusplus >= 202002L
575 static_assert(!__is_aggregate(HasDefaultCons
), "");
577 static_assert(__is_aggregate(HasDefaultCons
), "");
579 static_assert(!__is_aggregate(HasExplicitDefaultCons
), "");
580 static_assert(!__is_aggregate(HasInheritedCons
), "");
581 static_assert(__is_aggregate(HasNoInheritedCons
) == TrueAfterCpp14
, "");
582 static_assert(__is_aggregate(HasCopyAssign
), "");
583 static_assert(!__is_aggregate(NonTrivialDefault
), "");
584 static_assert(__is_aggregate(HasDest
), "");
585 static_assert(!__is_aggregate(HasPriv
), "");
586 static_assert(!__is_aggregate(HasProt
), "");
587 static_assert(__is_aggregate(HasRefAggregate
), "");
588 static_assert(__is_aggregate(HasNonPOD
), "");
589 static_assert(!__is_aggregate(HasVirt
), "");
590 static_assert(__is_aggregate(VirtAr
), "");
591 static_assert(__is_aggregate(HasInClassInit
) == TrueAfterCpp11
, "");
592 static_assert(!__is_aggregate(HasPrivateBase
), "");
593 static_assert(!__is_aggregate(HasProtectedBase
), "");
594 static_assert(!__is_aggregate(HasVirtBase
), "");
596 static_assert(__is_aggregate(AggregateTemplate
<int>), "");
597 static_assert(!__is_aggregate(NonAggregateTemplate
<int>), "");
599 static_assert(__is_aggregate(Vector
), ""); // Extension supported by GCC and Clang
600 static_assert(__is_aggregate(VectorExt
), "");
601 static_assert(__is_aggregate(ComplexInt
), "");
602 static_assert(__is_aggregate(ComplexFloat
), "");
607 int t01
[T(__is_arithmetic(float))];
608 int t02
[T(__is_arithmetic(double))];
609 int t03
[T(__is_arithmetic(long double))];
610 int t11
[T(__is_arithmetic(bool))];
611 int t12
[T(__is_arithmetic(char))];
612 int t13
[T(__is_arithmetic(signed char))];
613 int t14
[T(__is_arithmetic(unsigned char))];
614 //int t15[T(__is_arithmetic(char16_t))];
615 //int t16[T(__is_arithmetic(char32_t))];
616 int t17
[T(__is_arithmetic(wchar_t))];
617 int t18
[T(__is_arithmetic(short))];
618 int t19
[T(__is_arithmetic(unsigned short))];
619 int t20
[T(__is_arithmetic(int))];
620 int t21
[T(__is_arithmetic(unsigned int))];
621 int t22
[T(__is_arithmetic(long))];
622 int t23
[T(__is_arithmetic(unsigned long))];
624 int t24
[F(__is_arithmetic(Union
))];
625 int t25
[F(__is_arithmetic(UnionAr
))];
626 int t26
[F(__is_arithmetic(Derives
))];
627 int t27
[F(__is_arithmetic(ClassType
))];
628 int t28
[F(__is_arithmetic(Enum
))];
629 int t29
[F(__is_arithmetic(void))];
630 int t30
[F(__is_arithmetic(cvoid
))];
631 int t31
[F(__is_arithmetic(IntArNB
))];
634 void is_complete_type()
636 int t01
[T(__is_complete_type(float))];
637 int t02
[T(__is_complete_type(double))];
638 int t03
[T(__is_complete_type(long double))];
639 int t11
[T(__is_complete_type(bool))];
640 int t12
[T(__is_complete_type(char))];
641 int t13
[T(__is_complete_type(signed char))];
642 int t14
[T(__is_complete_type(unsigned char))];
643 //int t15[T(__is_complete_type(char16_t))];
644 //int t16[T(__is_complete_type(char32_t))];
645 int t17
[T(__is_complete_type(wchar_t))];
646 int t18
[T(__is_complete_type(short))];
647 int t19
[T(__is_complete_type(unsigned short))];
648 int t20
[T(__is_complete_type(int))];
649 int t21
[T(__is_complete_type(unsigned int))];
650 int t22
[T(__is_complete_type(long))];
651 int t23
[T(__is_complete_type(unsigned long))];
652 int t24
[T(__is_complete_type(ACompleteType
))];
654 int t30
[F(__is_complete_type(AnIncompleteType
))];
659 int t01
[T(__is_void(void))];
660 int t02
[T(__is_void(cvoid
))];
662 int t10
[F(__is_void(float))];
663 int t11
[F(__is_void(double))];
664 int t12
[F(__is_void(long double))];
665 int t13
[F(__is_void(bool))];
666 int t14
[F(__is_void(char))];
667 int t15
[F(__is_void(signed char))];
668 int t16
[F(__is_void(unsigned char))];
669 int t17
[F(__is_void(wchar_t))];
670 int t18
[F(__is_void(short))];
671 int t19
[F(__is_void(unsigned short))];
672 int t20
[F(__is_void(int))];
673 int t21
[F(__is_void(unsigned int))];
674 int t22
[F(__is_void(long))];
675 int t23
[F(__is_void(unsigned long))];
676 int t24
[F(__is_void(Union
))];
677 int t25
[F(__is_void(UnionAr
))];
678 int t26
[F(__is_void(Derives
))];
679 int t27
[F(__is_void(ClassType
))];
680 int t28
[F(__is_void(Enum
))];
681 int t29
[F(__is_void(IntArNB
))];
682 int t30
[F(__is_void(void*))];
683 int t31
[F(__is_void(cvoid
*))];
688 int t01
[T(__is_array(IntAr
))];
689 int t02
[T(__is_array(IntArNB
))];
690 int t03
[T(__is_array(UnionAr
))];
692 int t10
[F(__is_array(void))];
693 int t11
[F(__is_array(cvoid
))];
694 int t12
[F(__is_array(float))];
695 int t13
[F(__is_array(double))];
696 int t14
[F(__is_array(long double))];
697 int t15
[F(__is_array(bool))];
698 int t16
[F(__is_array(char))];
699 int t17
[F(__is_array(signed char))];
700 int t18
[F(__is_array(unsigned char))];
701 int t19
[F(__is_array(wchar_t))];
702 int t20
[F(__is_array(short))];
703 int t21
[F(__is_array(unsigned short))];
704 int t22
[F(__is_array(int))];
705 int t23
[F(__is_array(unsigned int))];
706 int t24
[F(__is_array(long))];
707 int t25
[F(__is_array(unsigned long))];
708 int t26
[F(__is_array(Union
))];
709 int t27
[F(__is_array(Derives
))];
710 int t28
[F(__is_array(ClassType
))];
711 int t29
[F(__is_array(Enum
))];
712 int t30
[F(__is_array(void*))];
713 int t31
[F(__is_array(cvoid
*))];
716 void is_bounded_array(int n
) {
717 static_assert(__is_bounded_array(IntAr
), "");
718 static_assert(!__is_bounded_array(IntArNB
), "");
719 static_assert(__is_bounded_array(UnionAr
), "");
721 static_assert(!__is_bounded_array(void), "");
722 static_assert(!__is_bounded_array(cvoid
), "");
723 static_assert(!__is_bounded_array(float), "");
724 static_assert(!__is_bounded_array(double), "");
725 static_assert(!__is_bounded_array(long double), "");
726 static_assert(!__is_bounded_array(bool), "");
727 static_assert(!__is_bounded_array(char), "");
728 static_assert(!__is_bounded_array(signed char), "");
729 static_assert(!__is_bounded_array(unsigned char), "");
730 static_assert(!__is_bounded_array(wchar_t), "");
731 static_assert(!__is_bounded_array(short), "");
732 static_assert(!__is_bounded_array(unsigned short), "");
733 static_assert(!__is_bounded_array(int), "");
734 static_assert(!__is_bounded_array(unsigned int), "");
735 static_assert(!__is_bounded_array(long), "");
736 static_assert(!__is_bounded_array(unsigned long), "");
737 static_assert(!__is_bounded_array(Union
), "");
738 static_assert(!__is_bounded_array(Derives
), "");
739 static_assert(!__is_bounded_array(ClassType
), "");
740 static_assert(!__is_bounded_array(Enum
), "");
741 static_assert(!__is_bounded_array(void *), "");
742 static_assert(!__is_bounded_array(cvoid
*), "");
745 (void)__is_bounded_array(decltype(t32
)); // expected-error{{variable length arrays are not supported for '__is_bounded_array'}}
748 void is_unbounded_array(int n
) {
749 static_assert(!__is_unbounded_array(IntAr
), "");
750 static_assert(__is_unbounded_array(IntArNB
), "");
751 static_assert(!__is_unbounded_array(UnionAr
), "");
753 static_assert(!__is_unbounded_array(void), "");
754 static_assert(!__is_unbounded_array(cvoid
), "");
755 static_assert(!__is_unbounded_array(float), "");
756 static_assert(!__is_unbounded_array(double), "");
757 static_assert(!__is_unbounded_array(long double), "");
758 static_assert(!__is_unbounded_array(bool), "");
759 static_assert(!__is_unbounded_array(char), "");
760 static_assert(!__is_unbounded_array(signed char), "");
761 static_assert(!__is_unbounded_array(unsigned char), "");
762 static_assert(!__is_unbounded_array(wchar_t), "");
763 static_assert(!__is_unbounded_array(short), "");
764 static_assert(!__is_unbounded_array(unsigned short), "");
765 static_assert(!__is_unbounded_array(int), "");
766 static_assert(!__is_unbounded_array(unsigned int), "");
767 static_assert(!__is_unbounded_array(long), "");
768 static_assert(!__is_unbounded_array(unsigned long), "");
769 static_assert(!__is_unbounded_array(Union
), "");
770 static_assert(!__is_unbounded_array(Derives
), "");
771 static_assert(!__is_unbounded_array(ClassType
), "");
772 static_assert(!__is_unbounded_array(Enum
), "");
773 static_assert(!__is_unbounded_array(void *), "");
774 static_assert(!__is_unbounded_array(cvoid
*), "");
777 (void)__is_unbounded_array(decltype(t32
)); // expected-error{{variable length arrays are not supported for '__is_unbounded_array'}}
780 void is_referenceable() {
781 static_assert(__is_referenceable(int), "");
782 static_assert(__is_referenceable(const int), "");
783 static_assert(__is_referenceable(volatile int), "");
784 static_assert(__is_referenceable(const volatile int), "");
785 static_assert(__is_referenceable(int *), "");
786 static_assert(__is_referenceable(int &), "");
787 static_assert(__is_referenceable(int &&), "");
788 static_assert(__is_referenceable(int (*)()), "");
789 static_assert(__is_referenceable(int (&)()), "");
790 static_assert(__is_referenceable(int(&&)()), "");
791 static_assert(__is_referenceable(IntAr
), "");
792 static_assert(__is_referenceable(IntArNB
), "");
793 static_assert(__is_referenceable(decltype(nullptr)), "");
794 static_assert(__is_referenceable(Empty
), "");
795 static_assert(__is_referenceable(Union
), "");
796 static_assert(__is_referenceable(Derives
), "");
797 static_assert(__is_referenceable(Enum
), "");
798 static_assert(__is_referenceable(EnumClass
), "");
799 static_assert(__is_referenceable(int Empty::*), "");
800 static_assert(__is_referenceable(int(Empty::*)()), "");
801 static_assert(__is_referenceable(AnIncompleteType
), "");
802 static_assert(__is_referenceable(struct AnIncompleteType
), "");
804 using function_type
= void(int);
805 static_assert(__is_referenceable(function_type
), "");
807 static_assert(!__is_referenceable(void), "");
810 template <typename T
> void tmpl_func(T
&) {}
812 template <typename T
> struct type_wrapper
{
820 int t01
[T(__is_function(type_wrapper
<void(void)>::type
))];
821 int t02
[T(__is_function(typeof(tmpl_func
<int>)))];
823 typedef void (*ptr_to_func_type
)(void);
825 int t10
[F(__is_function(void))];
826 int t11
[F(__is_function(cvoid
))];
827 int t12
[F(__is_function(float))];
828 int t13
[F(__is_function(double))];
829 int t14
[F(__is_function(long double))];
830 int t15
[F(__is_function(bool))];
831 int t16
[F(__is_function(char))];
832 int t17
[F(__is_function(signed char))];
833 int t18
[F(__is_function(unsigned char))];
834 int t19
[F(__is_function(wchar_t))];
835 int t20
[F(__is_function(short))];
836 int t21
[F(__is_function(unsigned short))];
837 int t22
[F(__is_function(int))];
838 int t23
[F(__is_function(unsigned int))];
839 int t24
[F(__is_function(long))];
840 int t25
[F(__is_function(unsigned long))];
841 int t26
[F(__is_function(Union
))];
842 int t27
[F(__is_function(Derives
))];
843 int t28
[F(__is_function(ClassType
))];
844 int t29
[F(__is_function(Enum
))];
845 int t30
[F(__is_function(void*))];
846 int t31
[F(__is_function(cvoid
*))];
847 int t32
[F(__is_function(void(*)()))];
848 int t33
[F(__is_function(ptr_to_func_type
))];
849 int t34
[F(__is_function(type_wrapper
<void(void)>::ptrtype
))];
850 int t35
[F(__is_function(type_wrapper
<void(void)>::reftype
))];
855 int t01
[T(__is_reference(int&))];
856 int t02
[T(__is_reference(const int&))];
857 int t03
[T(__is_reference(void *&))];
859 int t10
[F(__is_reference(int))];
860 int t11
[F(__is_reference(const int))];
861 int t12
[F(__is_reference(void *))];
864 void is_lvalue_reference()
866 int t01
[T(__is_lvalue_reference(int&))];
867 int t02
[T(__is_lvalue_reference(void *&))];
868 int t03
[T(__is_lvalue_reference(const int&))];
869 int t04
[T(__is_lvalue_reference(void * const &))];
871 int t10
[F(__is_lvalue_reference(int))];
872 int t11
[F(__is_lvalue_reference(const int))];
873 int t12
[F(__is_lvalue_reference(void *))];
876 #if __has_feature(cxx_rvalue_references)
878 void is_rvalue_reference()
880 int t01
[T(__is_rvalue_reference(const int&&))];
881 int t02
[T(__is_rvalue_reference(void * const &&))];
883 int t10
[F(__is_rvalue_reference(int&))];
884 int t11
[F(__is_rvalue_reference(void *&))];
885 int t12
[F(__is_rvalue_reference(const int&))];
886 int t13
[F(__is_rvalue_reference(void * const &))];
887 int t14
[F(__is_rvalue_reference(int))];
888 int t15
[F(__is_rvalue_reference(const int))];
889 int t16
[F(__is_rvalue_reference(void *))];
894 void is_fundamental()
896 int t01
[T(__is_fundamental(float))];
897 int t02
[T(__is_fundamental(double))];
898 int t03
[T(__is_fundamental(long double))];
899 int t11
[T(__is_fundamental(bool))];
900 int t12
[T(__is_fundamental(char))];
901 int t13
[T(__is_fundamental(signed char))];
902 int t14
[T(__is_fundamental(unsigned char))];
903 //int t15[T(__is_fundamental(char16_t))];
904 //int t16[T(__is_fundamental(char32_t))];
905 int t17
[T(__is_fundamental(wchar_t))];
906 int t18
[T(__is_fundamental(short))];
907 int t19
[T(__is_fundamental(unsigned short))];
908 int t20
[T(__is_fundamental(int))];
909 int t21
[T(__is_fundamental(unsigned int))];
910 int t22
[T(__is_fundamental(long))];
911 int t23
[T(__is_fundamental(unsigned long))];
912 int t24
[T(__is_fundamental(void))];
913 int t25
[T(__is_fundamental(cvoid
))];
914 int t26
[T(__is_fundamental(decltype(nullptr)))];
916 int t30
[F(__is_fundamental(Union
))];
917 int t31
[F(__is_fundamental(UnionAr
))];
918 int t32
[F(__is_fundamental(Derives
))];
919 int t33
[F(__is_fundamental(ClassType
))];
920 int t34
[F(__is_fundamental(Enum
))];
921 int t35
[F(__is_fundamental(IntArNB
))];
926 int t01
[T(__is_object(int))];
927 int t02
[T(__is_object(int *))];
928 int t03
[T(__is_object(void *))];
929 int t04
[T(__is_object(Union
))];
930 int t05
[T(__is_object(UnionAr
))];
931 int t06
[T(__is_object(ClassType
))];
932 int t07
[T(__is_object(Enum
))];
934 int t10
[F(__is_object(type_wrapper
<void(void)>::type
))];
935 int t11
[F(__is_object(int&))];
936 int t12
[F(__is_object(void))];
941 int t01
[T(__is_scalar(float))];
942 int t02
[T(__is_scalar(double))];
943 int t03
[T(__is_scalar(long double))];
944 int t04
[T(__is_scalar(bool))];
945 int t05
[T(__is_scalar(char))];
946 int t06
[T(__is_scalar(signed char))];
947 int t07
[T(__is_scalar(unsigned char))];
948 int t08
[T(__is_scalar(wchar_t))];
949 int t09
[T(__is_scalar(short))];
950 int t10
[T(__is_scalar(unsigned short))];
951 int t11
[T(__is_scalar(int))];
952 int t12
[T(__is_scalar(unsigned int))];
953 int t13
[T(__is_scalar(long))];
954 int t14
[T(__is_scalar(unsigned long))];
955 int t15
[T(__is_scalar(Enum
))];
956 int t16
[T(__is_scalar(void*))];
957 int t17
[T(__is_scalar(cvoid
*))];
959 int t20
[F(__is_scalar(void))];
960 int t21
[F(__is_scalar(cvoid
))];
961 int t22
[F(__is_scalar(Union
))];
962 int t23
[F(__is_scalar(UnionAr
))];
963 int t24
[F(__is_scalar(Derives
))];
964 int t25
[F(__is_scalar(ClassType
))];
965 int t26
[F(__is_scalar(IntArNB
))];
968 struct StructWithMembers
{
975 int t01
[T(__is_compound(void*))];
976 int t02
[T(__is_compound(cvoid
*))];
977 int t03
[T(__is_compound(void (*)()))];
978 int t04
[T(__is_compound(int StructWithMembers::*))];
979 int t05
[T(__is_compound(void (StructWithMembers::*)()))];
980 int t06
[T(__is_compound(int&))];
981 int t07
[T(__is_compound(Union
))];
982 int t08
[T(__is_compound(UnionAr
))];
983 int t09
[T(__is_compound(Derives
))];
984 int t10
[T(__is_compound(ClassType
))];
985 int t11
[T(__is_compound(IntArNB
))];
986 int t12
[T(__is_compound(Enum
))];
988 int t20
[F(__is_compound(float))];
989 int t21
[F(__is_compound(double))];
990 int t22
[F(__is_compound(long double))];
991 int t23
[F(__is_compound(bool))];
992 int t24
[F(__is_compound(char))];
993 int t25
[F(__is_compound(signed char))];
994 int t26
[F(__is_compound(unsigned char))];
995 int t27
[F(__is_compound(wchar_t))];
996 int t28
[F(__is_compound(short))];
997 int t29
[F(__is_compound(unsigned short))];
998 int t30
[F(__is_compound(int))];
999 int t31
[F(__is_compound(unsigned int))];
1000 int t32
[F(__is_compound(long))];
1001 int t33
[F(__is_compound(unsigned long))];
1002 int t34
[F(__is_compound(void))];
1003 int t35
[F(__is_compound(cvoid
))];
1008 StructWithMembers x
;
1010 int t01
[T(__is_pointer(void*))];
1011 int t02
[T(__is_pointer(cvoid
*))];
1012 int t03
[T(__is_pointer(cvoid
*))];
1013 int t04
[T(__is_pointer(char*))];
1014 int t05
[T(__is_pointer(int*))];
1015 int t06
[T(__is_pointer(int**))];
1016 int t07
[T(__is_pointer(ClassType
*))];
1017 int t08
[T(__is_pointer(Derives
*))];
1018 int t09
[T(__is_pointer(Enum
*))];
1019 int t10
[T(__is_pointer(IntArNB
*))];
1020 int t11
[T(__is_pointer(Union
*))];
1021 int t12
[T(__is_pointer(UnionAr
*))];
1022 int t13
[T(__is_pointer(StructWithMembers
*))];
1023 int t14
[T(__is_pointer(void (*)()))];
1025 int t20
[F(__is_pointer(void))];
1026 int t21
[F(__is_pointer(cvoid
))];
1027 int t22
[F(__is_pointer(cvoid
))];
1028 int t23
[F(__is_pointer(char))];
1029 int t24
[F(__is_pointer(int))];
1030 int t25
[F(__is_pointer(int))];
1031 int t26
[F(__is_pointer(ClassType
))];
1032 int t27
[F(__is_pointer(Derives
))];
1033 int t28
[F(__is_pointer(Enum
))];
1034 int t29
[F(__is_pointer(IntArNB
))];
1035 int t30
[F(__is_pointer(Union
))];
1036 int t31
[F(__is_pointer(UnionAr
))];
1037 int t32
[F(__is_pointer(StructWithMembers
))];
1038 int t33
[F(__is_pointer(int StructWithMembers::*))];
1039 int t34
[F(__is_pointer(void (StructWithMembers::*) ()))];
1042 void is_null_pointer() {
1043 StructWithMembers x
;
1045 static_assert(__is_nullptr(decltype(nullptr)), "");
1046 static_assert(!__is_nullptr(void *), "");
1047 static_assert(!__is_nullptr(cvoid
*), "");
1048 static_assert(!__is_nullptr(cvoid
*), "");
1049 static_assert(!__is_nullptr(char *), "");
1050 static_assert(!__is_nullptr(int *), "");
1051 static_assert(!__is_nullptr(int **), "");
1052 static_assert(!__is_nullptr(ClassType
*), "");
1053 static_assert(!__is_nullptr(Derives
*), "");
1054 static_assert(!__is_nullptr(Enum
*), "");
1055 static_assert(!__is_nullptr(IntArNB
*), "");
1056 static_assert(!__is_nullptr(Union
*), "");
1057 static_assert(!__is_nullptr(UnionAr
*), "");
1058 static_assert(!__is_nullptr(StructWithMembers
*), "");
1059 static_assert(!__is_nullptr(void (*)()), "");
1061 static_assert(!__is_nullptr(void), "");
1062 static_assert(!__is_nullptr(cvoid
), "");
1063 static_assert(!__is_nullptr(cvoid
), "");
1064 static_assert(!__is_nullptr(char), "");
1065 static_assert(!__is_nullptr(int), "");
1066 static_assert(!__is_nullptr(int), "");
1067 static_assert(!__is_nullptr(ClassType
), "");
1068 static_assert(!__is_nullptr(Derives
), "");
1069 static_assert(!__is_nullptr(Enum
), "");
1070 static_assert(!__is_nullptr(IntArNB
), "");
1071 static_assert(!__is_nullptr(Union
), "");
1072 static_assert(!__is_nullptr(UnionAr
), "");
1073 static_assert(!__is_nullptr(StructWithMembers
), "");
1074 static_assert(!__is_nullptr(int StructWithMembers::*), "");
1075 static_assert(!__is_nullptr(void(StructWithMembers::*)()), "");
1078 void is_member_object_pointer()
1080 StructWithMembers x
;
1082 int t01
[T(__is_member_object_pointer(int StructWithMembers::*))];
1084 int t10
[F(__is_member_object_pointer(void (StructWithMembers::*) ()))];
1085 int t11
[F(__is_member_object_pointer(void*))];
1086 int t12
[F(__is_member_object_pointer(cvoid
*))];
1087 int t13
[F(__is_member_object_pointer(cvoid
*))];
1088 int t14
[F(__is_member_object_pointer(char*))];
1089 int t15
[F(__is_member_object_pointer(int*))];
1090 int t16
[F(__is_member_object_pointer(int**))];
1091 int t17
[F(__is_member_object_pointer(ClassType
*))];
1092 int t18
[F(__is_member_object_pointer(Derives
*))];
1093 int t19
[F(__is_member_object_pointer(Enum
*))];
1094 int t20
[F(__is_member_object_pointer(IntArNB
*))];
1095 int t21
[F(__is_member_object_pointer(Union
*))];
1096 int t22
[F(__is_member_object_pointer(UnionAr
*))];
1097 int t23
[F(__is_member_object_pointer(StructWithMembers
*))];
1098 int t24
[F(__is_member_object_pointer(void))];
1099 int t25
[F(__is_member_object_pointer(cvoid
))];
1100 int t26
[F(__is_member_object_pointer(cvoid
))];
1101 int t27
[F(__is_member_object_pointer(char))];
1102 int t28
[F(__is_member_object_pointer(int))];
1103 int t29
[F(__is_member_object_pointer(int))];
1104 int t30
[F(__is_member_object_pointer(ClassType
))];
1105 int t31
[F(__is_member_object_pointer(Derives
))];
1106 int t32
[F(__is_member_object_pointer(Enum
))];
1107 int t33
[F(__is_member_object_pointer(IntArNB
))];
1108 int t34
[F(__is_member_object_pointer(Union
))];
1109 int t35
[F(__is_member_object_pointer(UnionAr
))];
1110 int t36
[F(__is_member_object_pointer(StructWithMembers
))];
1111 int t37
[F(__is_member_object_pointer(void (*)()))];
1114 void is_member_function_pointer()
1116 StructWithMembers x
;
1118 int t01
[T(__is_member_function_pointer(void (StructWithMembers::*) ()))];
1120 int t10
[F(__is_member_function_pointer(int StructWithMembers::*))];
1121 int t11
[F(__is_member_function_pointer(void*))];
1122 int t12
[F(__is_member_function_pointer(cvoid
*))];
1123 int t13
[F(__is_member_function_pointer(cvoid
*))];
1124 int t14
[F(__is_member_function_pointer(char*))];
1125 int t15
[F(__is_member_function_pointer(int*))];
1126 int t16
[F(__is_member_function_pointer(int**))];
1127 int t17
[F(__is_member_function_pointer(ClassType
*))];
1128 int t18
[F(__is_member_function_pointer(Derives
*))];
1129 int t19
[F(__is_member_function_pointer(Enum
*))];
1130 int t20
[F(__is_member_function_pointer(IntArNB
*))];
1131 int t21
[F(__is_member_function_pointer(Union
*))];
1132 int t22
[F(__is_member_function_pointer(UnionAr
*))];
1133 int t23
[F(__is_member_function_pointer(StructWithMembers
*))];
1134 int t24
[F(__is_member_function_pointer(void))];
1135 int t25
[F(__is_member_function_pointer(cvoid
))];
1136 int t26
[F(__is_member_function_pointer(cvoid
))];
1137 int t27
[F(__is_member_function_pointer(char))];
1138 int t28
[F(__is_member_function_pointer(int))];
1139 int t29
[F(__is_member_function_pointer(int))];
1140 int t30
[F(__is_member_function_pointer(ClassType
))];
1141 int t31
[F(__is_member_function_pointer(Derives
))];
1142 int t32
[F(__is_member_function_pointer(Enum
))];
1143 int t33
[F(__is_member_function_pointer(IntArNB
))];
1144 int t34
[F(__is_member_function_pointer(Union
))];
1145 int t35
[F(__is_member_function_pointer(UnionAr
))];
1146 int t36
[F(__is_member_function_pointer(StructWithMembers
))];
1147 int t37
[F(__is_member_function_pointer(void (*)()))];
1150 void is_member_pointer()
1152 StructWithMembers x
;
1154 int t01
[T(__is_member_pointer(int StructWithMembers::*))];
1155 int t02
[T(__is_member_pointer(void (StructWithMembers::*) ()))];
1157 int t10
[F(__is_member_pointer(void*))];
1158 int t11
[F(__is_member_pointer(cvoid
*))];
1159 int t12
[F(__is_member_pointer(cvoid
*))];
1160 int t13
[F(__is_member_pointer(char*))];
1161 int t14
[F(__is_member_pointer(int*))];
1162 int t15
[F(__is_member_pointer(int**))];
1163 int t16
[F(__is_member_pointer(ClassType
*))];
1164 int t17
[F(__is_member_pointer(Derives
*))];
1165 int t18
[F(__is_member_pointer(Enum
*))];
1166 int t19
[F(__is_member_pointer(IntArNB
*))];
1167 int t20
[F(__is_member_pointer(Union
*))];
1168 int t21
[F(__is_member_pointer(UnionAr
*))];
1169 int t22
[F(__is_member_pointer(StructWithMembers
*))];
1170 int t23
[F(__is_member_pointer(void))];
1171 int t24
[F(__is_member_pointer(cvoid
))];
1172 int t25
[F(__is_member_pointer(cvoid
))];
1173 int t26
[F(__is_member_pointer(char))];
1174 int t27
[F(__is_member_pointer(int))];
1175 int t28
[F(__is_member_pointer(int))];
1176 int t29
[F(__is_member_pointer(ClassType
))];
1177 int t30
[F(__is_member_pointer(Derives
))];
1178 int t31
[F(__is_member_pointer(Enum
))];
1179 int t32
[F(__is_member_pointer(IntArNB
))];
1180 int t33
[F(__is_member_pointer(Union
))];
1181 int t34
[F(__is_member_pointer(UnionAr
))];
1182 int t35
[F(__is_member_pointer(StructWithMembers
))];
1183 int t36
[F(__is_member_pointer(void (*)()))];
1188 int t01
[T(__is_const(cvoid
))];
1189 int t02
[T(__is_const(const char))];
1190 int t03
[T(__is_const(const int))];
1191 int t04
[T(__is_const(const long))];
1192 int t05
[T(__is_const(const short))];
1193 int t06
[T(__is_const(const signed char))];
1194 int t07
[T(__is_const(const wchar_t))];
1195 int t08
[T(__is_const(const bool))];
1196 int t09
[T(__is_const(const float))];
1197 int t10
[T(__is_const(const double))];
1198 int t11
[T(__is_const(const long double))];
1199 int t12
[T(__is_const(const unsigned char))];
1200 int t13
[T(__is_const(const unsigned int))];
1201 int t14
[T(__is_const(const unsigned long long))];
1202 int t15
[T(__is_const(const unsigned long))];
1203 int t16
[T(__is_const(const unsigned short))];
1204 int t17
[T(__is_const(const void))];
1205 int t18
[T(__is_const(const ClassType
))];
1206 int t19
[T(__is_const(const Derives
))];
1207 int t20
[T(__is_const(const Enum
))];
1208 int t21
[T(__is_const(const IntArNB
))];
1209 int t22
[T(__is_const(const Union
))];
1210 int t23
[T(__is_const(const UnionAr
))];
1212 int t30
[F(__is_const(char))];
1213 int t31
[F(__is_const(int))];
1214 int t32
[F(__is_const(long))];
1215 int t33
[F(__is_const(short))];
1216 int t34
[F(__is_const(signed char))];
1217 int t35
[F(__is_const(wchar_t))];
1218 int t36
[F(__is_const(bool))];
1219 int t37
[F(__is_const(float))];
1220 int t38
[F(__is_const(double))];
1221 int t39
[F(__is_const(long double))];
1222 int t40
[F(__is_const(unsigned char))];
1223 int t41
[F(__is_const(unsigned int))];
1224 int t42
[F(__is_const(unsigned long long))];
1225 int t43
[F(__is_const(unsigned long))];
1226 int t44
[F(__is_const(unsigned short))];
1227 int t45
[F(__is_const(void))];
1228 int t46
[F(__is_const(ClassType
))];
1229 int t47
[F(__is_const(Derives
))];
1230 int t48
[F(__is_const(Enum
))];
1231 int t49
[F(__is_const(IntArNB
))];
1232 int t50
[F(__is_const(Union
))];
1233 int t51
[F(__is_const(UnionAr
))];
1238 int t02
[T(__is_volatile(volatile char))];
1239 int t03
[T(__is_volatile(volatile int))];
1240 int t04
[T(__is_volatile(volatile long))];
1241 int t05
[T(__is_volatile(volatile short))];
1242 int t06
[T(__is_volatile(volatile signed char))];
1243 int t07
[T(__is_volatile(volatile wchar_t))];
1244 int t08
[T(__is_volatile(volatile bool))];
1245 int t09
[T(__is_volatile(volatile float))];
1246 int t10
[T(__is_volatile(volatile double))];
1247 int t11
[T(__is_volatile(volatile long double))];
1248 int t12
[T(__is_volatile(volatile unsigned char))];
1249 int t13
[T(__is_volatile(volatile unsigned int))];
1250 int t14
[T(__is_volatile(volatile unsigned long long))];
1251 int t15
[T(__is_volatile(volatile unsigned long))];
1252 int t16
[T(__is_volatile(volatile unsigned short))];
1253 int t17
[T(__is_volatile(volatile void))];
1254 int t18
[T(__is_volatile(volatile ClassType
))];
1255 int t19
[T(__is_volatile(volatile Derives
))];
1256 int t20
[T(__is_volatile(volatile Enum
))];
1257 int t21
[T(__is_volatile(volatile IntArNB
))];
1258 int t22
[T(__is_volatile(volatile Union
))];
1259 int t23
[T(__is_volatile(volatile UnionAr
))];
1261 int t30
[F(__is_volatile(char))];
1262 int t31
[F(__is_volatile(int))];
1263 int t32
[F(__is_volatile(long))];
1264 int t33
[F(__is_volatile(short))];
1265 int t34
[F(__is_volatile(signed char))];
1266 int t35
[F(__is_volatile(wchar_t))];
1267 int t36
[F(__is_volatile(bool))];
1268 int t37
[F(__is_volatile(float))];
1269 int t38
[F(__is_volatile(double))];
1270 int t39
[F(__is_volatile(long double))];
1271 int t40
[F(__is_volatile(unsigned char))];
1272 int t41
[F(__is_volatile(unsigned int))];
1273 int t42
[F(__is_volatile(unsigned long long))];
1274 int t43
[F(__is_volatile(unsigned long))];
1275 int t44
[F(__is_volatile(unsigned short))];
1276 int t45
[F(__is_volatile(void))];
1277 int t46
[F(__is_volatile(ClassType
))];
1278 int t47
[F(__is_volatile(Derives
))];
1279 int t48
[F(__is_volatile(Enum
))];
1280 int t49
[F(__is_volatile(IntArNB
))];
1281 int t50
[F(__is_volatile(Union
))];
1282 int t51
[F(__is_volatile(UnionAr
))];
1285 struct TrivialStruct
{
1289 struct NonTrivialStruct
{
1291 NonTrivialStruct() {
1296 struct SuperNonTrivialStruct
{
1297 SuperNonTrivialStruct() { }
1298 ~SuperNonTrivialStruct() { }
1301 struct NonTCStruct
{
1302 NonTCStruct(const NonTCStruct
&) {}
1305 struct AllDefaulted
{
1306 AllDefaulted() = default;
1307 AllDefaulted(const AllDefaulted
&) = default;
1308 AllDefaulted(AllDefaulted
&&) = default;
1309 AllDefaulted
&operator=(const AllDefaulted
&) = default;
1310 AllDefaulted
&operator=(AllDefaulted
&&) = default;
1311 ~AllDefaulted() = default;
1314 struct NoDefaultMoveAssignDueToUDCopyCtor
{
1315 NoDefaultMoveAssignDueToUDCopyCtor(const NoDefaultMoveAssignDueToUDCopyCtor
&);
1318 struct NoDefaultMoveAssignDueToUDCopyAssign
{
1319 NoDefaultMoveAssignDueToUDCopyAssign
& operator=(
1320 const NoDefaultMoveAssignDueToUDCopyAssign
&);
1323 struct NoDefaultMoveAssignDueToDtor
{
1324 ~NoDefaultMoveAssignDueToDtor();
1328 AllDeleted() = delete;
1329 AllDeleted(const AllDeleted
&) = delete;
1330 AllDeleted(AllDeleted
&&) = delete;
1331 AllDeleted
&operator=(const AllDeleted
&) = delete;
1332 AllDeleted
&operator=(AllDeleted
&&) = delete;
1333 ~AllDeleted() = delete;
1336 struct ExtDefaulted
{
1338 ExtDefaulted(const ExtDefaulted
&);
1339 ExtDefaulted(ExtDefaulted
&&);
1340 ExtDefaulted
&operator=(const ExtDefaulted
&);
1341 ExtDefaulted
&operator=(ExtDefaulted
&&);
1345 // Despite being defaulted, these functions are not trivial.
1346 ExtDefaulted::ExtDefaulted() = default;
1347 ExtDefaulted::ExtDefaulted(const ExtDefaulted
&) = default;
1348 ExtDefaulted::ExtDefaulted(ExtDefaulted
&&) = default;
1349 ExtDefaulted
&ExtDefaulted::operator=(const ExtDefaulted
&) = default;
1350 ExtDefaulted
&ExtDefaulted::operator=(ExtDefaulted
&&) = default;
1351 ExtDefaulted::~ExtDefaulted() = default;
1355 int t01
[T(__is_trivial(char))];
1356 int t02
[T(__is_trivial(int))];
1357 int t03
[T(__is_trivial(long))];
1358 int t04
[T(__is_trivial(short))];
1359 int t05
[T(__is_trivial(signed char))];
1360 int t06
[T(__is_trivial(wchar_t))];
1361 int t07
[T(__is_trivial(bool))];
1362 int t08
[T(__is_trivial(float))];
1363 int t09
[T(__is_trivial(double))];
1364 int t10
[T(__is_trivial(long double))];
1365 int t11
[T(__is_trivial(unsigned char))];
1366 int t12
[T(__is_trivial(unsigned int))];
1367 int t13
[T(__is_trivial(unsigned long long))];
1368 int t14
[T(__is_trivial(unsigned long))];
1369 int t15
[T(__is_trivial(unsigned short))];
1370 int t16
[T(__is_trivial(ClassType
))];
1371 int t17
[T(__is_trivial(Derives
))];
1372 int t18
[T(__is_trivial(Enum
))];
1373 int t19
[T(__is_trivial(IntAr
))];
1374 int t20
[T(__is_trivial(Union
))];
1375 int t21
[T(__is_trivial(UnionAr
))];
1376 int t22
[T(__is_trivial(TrivialStruct
))];
1377 int t23
[T(__is_trivial(AllDefaulted
))];
1378 int t24
[T(__is_trivial(AllDeleted
))];
1380 int t30
[F(__is_trivial(void))];
1381 int t31
[F(__is_trivial(NonTrivialStruct
))];
1382 int t32
[F(__is_trivial(SuperNonTrivialStruct
))];
1383 int t33
[F(__is_trivial(NonTCStruct
))];
1384 int t34
[F(__is_trivial(ExtDefaulted
))];
1386 int t40
[T(__is_trivial(ACompleteType
))];
1387 int t41
[F(__is_trivial(AnIncompleteType
))]; // expected-error {{incomplete type}}
1388 int t42
[F(__is_trivial(AnIncompleteType
[]))]; // expected-error {{incomplete type}}
1389 int t43
[F(__is_trivial(AnIncompleteType
[1]))]; // expected-error {{incomplete type}}
1390 int t44
[F(__is_trivial(void))];
1391 int t45
[F(__is_trivial(const volatile void))];
1394 void is_trivially_copyable2()
1396 int t01
[T(__is_trivially_copyable(char))];
1397 int t02
[T(__is_trivially_copyable(int))];
1398 int t03
[T(__is_trivially_copyable(long))];
1399 int t04
[T(__is_trivially_copyable(short))];
1400 int t05
[T(__is_trivially_copyable(signed char))];
1401 int t06
[T(__is_trivially_copyable(wchar_t))];
1402 int t07
[T(__is_trivially_copyable(bool))];
1403 int t08
[T(__is_trivially_copyable(float))];
1404 int t09
[T(__is_trivially_copyable(double))];
1405 int t10
[T(__is_trivially_copyable(long double))];
1406 int t11
[T(__is_trivially_copyable(unsigned char))];
1407 int t12
[T(__is_trivially_copyable(unsigned int))];
1408 int t13
[T(__is_trivially_copyable(unsigned long long))];
1409 int t14
[T(__is_trivially_copyable(unsigned long))];
1410 int t15
[T(__is_trivially_copyable(unsigned short))];
1411 int t16
[T(__is_trivially_copyable(ClassType
))];
1412 int t17
[T(__is_trivially_copyable(Derives
))];
1413 int t18
[T(__is_trivially_copyable(Enum
))];
1414 int t19
[T(__is_trivially_copyable(IntAr
))];
1415 int t20
[T(__is_trivially_copyable(Union
))];
1416 int t21
[T(__is_trivially_copyable(UnionAr
))];
1417 int t22
[T(__is_trivially_copyable(TrivialStruct
))];
1418 int t23
[T(__is_trivially_copyable(NonTrivialStruct
))];
1419 int t24
[T(__is_trivially_copyable(AllDefaulted
))];
1420 int t25
[T(__is_trivially_copyable(AllDeleted
))];
1422 int t30
[F(__is_trivially_copyable(void))];
1423 int t31
[F(__is_trivially_copyable(SuperNonTrivialStruct
))];
1424 int t32
[F(__is_trivially_copyable(NonTCStruct
))];
1425 int t33
[F(__is_trivially_copyable(ExtDefaulted
))];
1427 int t34
[T(__is_trivially_copyable(const int))];
1428 int t35
[T(__is_trivially_copyable(volatile int))];
1430 int t40
[T(__is_trivially_copyable(ACompleteType
))];
1431 int t41
[F(__is_trivially_copyable(AnIncompleteType
))]; // expected-error {{incomplete type}}
1432 int t42
[F(__is_trivially_copyable(AnIncompleteType
[]))]; // expected-error {{incomplete type}}
1433 int t43
[F(__is_trivially_copyable(AnIncompleteType
[1]))]; // expected-error {{incomplete type}}
1434 int t44
[F(__is_trivially_copyable(void))];
1435 int t45
[F(__is_trivially_copyable(const volatile void))];
1443 struct CEmptyStruct
{};
1445 struct CppEmptyStruct
: CStruct
{};
1446 struct CppStructStandard
: CEmptyStruct
{
1450 struct CppStructNonStandardByBase
: CStruct
{
1454 struct CppStructNonStandardByVirt
: CStruct
{
1455 virtual void method() {}
1457 struct CppStructNonStandardByMemb
: CStruct
{
1458 CppStructNonStandardByVirt member
;
1460 struct CppStructNonStandardByProt
: CStruct
{
1465 struct CppStructNonStandardByVirtBase
: virtual CStruct
{
1467 struct CppStructNonStandardBySameBase
: CEmptyStruct
{
1468 CEmptyStruct member
;
1470 struct CppStructNonStandardBy2ndVirtBase
: CEmptyStruct
{
1471 CEmptyStruct member
;
1474 void is_standard_layout()
1476 typedef const int ConstInt
;
1477 typedef ConstInt ConstIntAr
[4];
1478 typedef CppStructStandard CppStructStandardAr
[4];
1480 int t01
[T(__is_standard_layout(int))];
1481 int t02
[T(__is_standard_layout(ConstInt
))];
1482 int t03
[T(__is_standard_layout(ConstIntAr
))];
1483 int t04
[T(__is_standard_layout(CStruct
))];
1484 int t05
[T(__is_standard_layout(CppStructStandard
))];
1485 int t06
[T(__is_standard_layout(CppStructStandardAr
))];
1486 int t07
[T(__is_standard_layout(Vector
))];
1487 int t08
[T(__is_standard_layout(VectorExt
))];
1489 typedef CppStructNonStandardByBase CppStructNonStandardByBaseAr
[4];
1491 int t10
[F(__is_standard_layout(CppStructNonStandardByVirt
))];
1492 int t11
[F(__is_standard_layout(CppStructNonStandardByMemb
))];
1493 int t12
[F(__is_standard_layout(CppStructNonStandardByProt
))];
1494 int t13
[F(__is_standard_layout(CppStructNonStandardByVirtBase
))];
1495 int t14
[F(__is_standard_layout(CppStructNonStandardByBase
))];
1496 int t15
[F(__is_standard_layout(CppStructNonStandardByBaseAr
))];
1497 int t16
[F(__is_standard_layout(CppStructNonStandardBySameBase
))];
1498 int t17
[F(__is_standard_layout(CppStructNonStandardBy2ndVirtBase
))];
1500 int t40
[T(__is_standard_layout(ACompleteType
))];
1501 int t41
[F(__is_standard_layout(AnIncompleteType
))]; // expected-error {{incomplete type}}
1502 int t42
[F(__is_standard_layout(AnIncompleteType
[]))]; // expected-error {{incomplete type}}
1503 int t43
[F(__is_standard_layout(AnIncompleteType
[1]))]; // expected-error {{incomplete type}}
1504 int t44
[F(__is_standard_layout(void))];
1505 int t45
[F(__is_standard_layout(const volatile void))];
1507 struct HasAnonEmptyBitfield
{ int : 0; };
1508 struct HasAnonBitfield
{ int : 4; };
1509 struct DerivesFromBitfield
: HasAnonBitfield
{};
1510 struct DerivesFromBitfieldWithBitfield
: HasAnonBitfield
{ int : 5; };
1511 struct DerivesFromBitfieldTwice
: DerivesFromBitfield
, HasAnonEmptyBitfield
{};
1513 int t50
[T(__is_standard_layout(HasAnonEmptyBitfield
))];
1514 int t51
[T(__is_standard_layout(HasAnonBitfield
))];
1515 int t52
[T(__is_standard_layout(DerivesFromBitfield
))];
1516 int t53
[F(__is_standard_layout(DerivesFromBitfieldWithBitfield
))];
1517 int t54
[F(__is_standard_layout(DerivesFromBitfieldTwice
))];
1520 struct HasEmptyBase
: Empty
{};
1521 struct HoldsEmptyBase
{ Empty e
; };
1522 struct HasRepeatedEmptyBase
: Empty
, HasEmptyBase
{}; // expected-warning {{inaccessible}}
1523 struct HasEmptyBaseAsMember
: Empty
{ Empty e
; };
1524 struct HasEmptyBaseAsSubobjectOfMember1
: Empty
{ HoldsEmptyBase e
; };
1525 struct HasEmptyBaseAsSubobjectOfMember2
: Empty
{ HasEmptyBase e
; };
1526 struct HasEmptyBaseAsSubobjectOfMember3
: Empty
{ HoldsEmptyBase e
[2]; };
1527 struct HasEmptyIndirectBaseAsMember
: HasEmptyBase
{ Empty e
; };
1528 struct HasEmptyIndirectBaseAsSecondMember
: HasEmptyBase
{ int n
; Empty e
; };
1529 struct HasEmptyIndirectBaseAfterBitfield
: HasEmptyBase
{ int : 4; Empty e
; };
1531 int t60
[T(__is_standard_layout(Empty
))];
1532 int t61
[T(__is_standard_layout(HasEmptyBase
))];
1533 int t62
[F(__is_standard_layout(HasRepeatedEmptyBase
))];
1534 int t63
[F(__is_standard_layout(HasEmptyBaseAsMember
))];
1535 int t64
[F(__is_standard_layout(HasEmptyBaseAsSubobjectOfMember1
))];
1536 int t65
[T(__is_standard_layout(HasEmptyBaseAsSubobjectOfMember2
))]; // FIXME: standard bug?
1537 int t66
[F(__is_standard_layout(HasEmptyBaseAsSubobjectOfMember3
))];
1538 int t67
[F(__is_standard_layout(HasEmptyIndirectBaseAsMember
))];
1539 int t68
[T(__is_standard_layout(HasEmptyIndirectBaseAsSecondMember
))];
1540 int t69
[F(__is_standard_layout(HasEmptyIndirectBaseAfterBitfield
))]; // FIXME: standard bug?
1542 struct StructWithEmptyFields
{
1544 HoldsEmptyBase e
[3];
1546 union UnionWithEmptyFields
{
1548 HoldsEmptyBase e
[3];
1550 struct HasEmptyIndirectBaseAsSecondStructMember
: HasEmptyBase
{
1551 StructWithEmptyFields u
;
1553 struct HasEmptyIndirectBaseAsSecondUnionMember
: HasEmptyBase
{
1554 UnionWithEmptyFields u
;
1557 int t70
[T(__is_standard_layout(HasEmptyIndirectBaseAsSecondStructMember
))];
1558 int t71
[F(__is_standard_layout(HasEmptyIndirectBaseAsSecondUnionMember
))];
1563 //int t01[T(__is_signed(char))];
1564 int t02
[T(__is_signed(int))];
1565 int t03
[T(__is_signed(long))];
1566 int t04
[T(__is_signed(short))];
1567 int t05
[T(__is_signed(signed char))];
1568 int t06
[T(__is_signed(wchar_t))];
1569 int t07
[T(__is_signed(float))];
1570 int t08
[T(__is_signed(double))];
1571 int t09
[T(__is_signed(long double))];
1573 int t13
[F(__is_signed(bool))];
1574 int t14
[F(__is_signed(cvoid
))];
1575 int t15
[F(__is_signed(unsigned char))];
1576 int t16
[F(__is_signed(unsigned int))];
1577 int t17
[F(__is_signed(unsigned long long))];
1578 int t18
[F(__is_signed(unsigned long))];
1579 int t19
[F(__is_signed(unsigned short))];
1580 int t20
[F(__is_signed(void))];
1581 int t21
[F(__is_signed(ClassType
))];
1582 int t22
[F(__is_signed(Derives
))];
1583 int t23
[F(__is_signed(Enum
))];
1584 int t24
[F(__is_signed(SignedEnum
))];
1585 int t25
[F(__is_signed(IntArNB
))];
1586 int t26
[F(__is_signed(Union
))];
1587 int t27
[F(__is_signed(UnionAr
))];
1588 int t28
[F(__is_signed(UnsignedEnum
))];
1593 int t01
[T(__is_unsigned(bool))];
1594 int t02
[T(__is_unsigned(unsigned char))];
1595 int t03
[T(__is_unsigned(unsigned short))];
1596 int t04
[T(__is_unsigned(unsigned int))];
1597 int t05
[T(__is_unsigned(unsigned long))];
1598 int t06
[T(__is_unsigned(unsigned long long))];
1600 int t10
[F(__is_unsigned(void))];
1601 int t11
[F(__is_unsigned(cvoid
))];
1602 int t12
[F(__is_unsigned(float))];
1603 int t13
[F(__is_unsigned(double))];
1604 int t14
[F(__is_unsigned(long double))];
1605 int t16
[F(__is_unsigned(char))];
1606 int t17
[F(__is_unsigned(signed char))];
1607 int t18
[F(__is_unsigned(wchar_t))];
1608 int t19
[F(__is_unsigned(short))];
1609 int t20
[F(__is_unsigned(int))];
1610 int t21
[F(__is_unsigned(long))];
1611 int t22
[F(__is_unsigned(Union
))];
1612 int t23
[F(__is_unsigned(UnionAr
))];
1613 int t24
[F(__is_unsigned(Derives
))];
1614 int t25
[F(__is_unsigned(ClassType
))];
1615 int t26
[F(__is_unsigned(IntArNB
))];
1616 int t27
[F(__is_unsigned(Enum
))];
1617 int t28
[F(__is_unsigned(UnsignedEnum
))];
1618 int t29
[F(__is_unsigned(SignedEnum
))];
1621 typedef Int
& IntRef
;
1622 typedef const IntAr ConstIntAr
;
1623 typedef ConstIntAr ConstIntArAr
[4];
1626 HasCopy(HasCopy
& cp
);
1630 HasMove(HasMove
&& cp
);
1633 struct HasTemplateCons
{
1636 template <typename T
>
1637 HasTemplateCons(const T
&);
1640 void has_trivial_default_constructor() {
1641 { int arr
[T(__has_trivial_constructor(Int
))]; }
1642 { int arr
[T(__has_trivial_constructor(IntAr
))]; }
1643 { int arr
[T(__has_trivial_constructor(Union
))]; }
1644 { int arr
[T(__has_trivial_constructor(UnionAr
))]; }
1645 { int arr
[T(__has_trivial_constructor(POD
))]; }
1646 { int arr
[T(__has_trivial_constructor(Derives
))]; }
1647 { int arr
[T(__has_trivial_constructor(DerivesAr
))]; }
1648 { int arr
[T(__has_trivial_constructor(ConstIntAr
))]; }
1649 { int arr
[T(__has_trivial_constructor(ConstIntArAr
))]; }
1650 { int arr
[T(__has_trivial_constructor(HasDest
))]; }
1651 { int arr
[T(__has_trivial_constructor(HasPriv
))]; }
1652 { int arr
[T(__has_trivial_constructor(HasCopyAssign
))]; }
1653 { int arr
[T(__has_trivial_constructor(HasMoveAssign
))]; }
1654 { int arr
[T(__has_trivial_constructor(const Int
))]; }
1655 { int arr
[T(__has_trivial_constructor(AllDefaulted
))]; }
1656 { int arr
[T(__has_trivial_constructor(AllDeleted
))]; }
1657 { int arr
[T(__has_trivial_constructor(ACompleteType
[]))]; }
1659 { int arr
[F(__has_trivial_constructor(AnIncompleteType
[]))]; } // expected-error {{incomplete type}}
1660 { int arr
[F(__has_trivial_constructor(HasCons
))]; }
1661 { int arr
[F(__has_trivial_constructor(HasRef
))]; }
1662 { int arr
[F(__has_trivial_constructor(HasCopy
))]; }
1663 { int arr
[F(__has_trivial_constructor(IntRef
))]; }
1664 { int arr
[F(__has_trivial_constructor(VirtAr
))]; }
1665 { int arr
[F(__has_trivial_constructor(void))]; }
1666 { int arr
[F(__has_trivial_constructor(cvoid
))]; }
1667 { int arr
[F(__has_trivial_constructor(HasTemplateCons
))]; }
1668 { int arr
[F(__has_trivial_constructor(AllPrivate
))]; }
1669 { int arr
[F(__has_trivial_constructor(ExtDefaulted
))]; }
1672 void has_trivial_move_constructor() {
1673 // n3376 12.8 [class.copy]/12
1674 // A copy/move constructor for class X is trivial if it is not
1675 // user-provided, its declared parameter type is the same as
1676 // if it had been implicitly declared, and if
1677 // - class X has no virtual functions (10.3) and no virtual
1678 // base classes (10.1), and
1679 // - the constructor selected to copy/move each direct base
1680 // class subobject is trivial, and
1681 // - for each non-static data member of X that is of class
1682 // type (or array thereof), the constructor selected
1683 // to copy/move that member is trivial;
1684 // otherwise the copy/move constructor is non-trivial.
1685 { int arr
[T(__has_trivial_move_constructor(POD
))]; }
1686 { int arr
[T(__has_trivial_move_constructor(Union
))]; }
1687 { int arr
[T(__has_trivial_move_constructor(HasCons
))]; }
1688 { int arr
[T(__has_trivial_move_constructor(HasStaticMemberMoveCtor
))]; }
1689 { int arr
[T(__has_trivial_move_constructor(AllDeleted
))]; }
1690 { int arr
[T(__has_trivial_move_constructor(ACompleteType
[]))]; }
1692 { int arr
[F(__has_trivial_move_constructor(AnIncompleteType
[]))]; } // expected-error {{incomplete type}}
1693 { int arr
[F(__has_trivial_move_constructor(HasVirt
))]; }
1694 { int arr
[F(__has_trivial_move_constructor(DerivesVirt
))]; }
1695 { int arr
[F(__has_trivial_move_constructor(HasMoveCtor
))]; }
1696 { int arr
[F(__has_trivial_move_constructor(DerivesHasMoveCtor
))]; }
1697 { int arr
[F(__has_trivial_move_constructor(HasMemberMoveCtor
))]; }
1700 void has_trivial_copy_constructor() {
1701 { int arr
[T(__has_trivial_copy(Int
))]; }
1702 { int arr
[T(__has_trivial_copy(IntAr
))]; }
1703 { int arr
[T(__has_trivial_copy(Union
))]; }
1704 { int arr
[T(__has_trivial_copy(UnionAr
))]; }
1705 { int arr
[T(__has_trivial_copy(POD
))]; }
1706 { int arr
[T(__has_trivial_copy(Derives
))]; }
1707 { int arr
[T(__has_trivial_copy(ConstIntAr
))]; }
1708 { int arr
[T(__has_trivial_copy(ConstIntArAr
))]; }
1709 { int arr
[T(__has_trivial_copy(HasDest
))]; }
1710 { int arr
[T(__has_trivial_copy(HasPriv
))]; }
1711 { int arr
[T(__has_trivial_copy(HasCons
))]; }
1712 { int arr
[T(__has_trivial_copy(HasRef
))]; }
1713 { int arr
[T(__has_trivial_copy(HasMove
))]; }
1714 { int arr
[T(__has_trivial_copy(IntRef
))]; }
1715 { int arr
[T(__has_trivial_copy(HasCopyAssign
))]; }
1716 { int arr
[T(__has_trivial_copy(HasMoveAssign
))]; }
1717 { int arr
[T(__has_trivial_copy(const Int
))]; }
1718 { int arr
[T(__has_trivial_copy(AllDefaulted
))]; }
1719 { int arr
[T(__has_trivial_copy(AllDeleted
))]; }
1720 { int arr
[T(__has_trivial_copy(DerivesAr
))]; }
1721 { int arr
[T(__has_trivial_copy(DerivesHasRef
))]; }
1722 { int arr
[T(__has_trivial_copy(ACompleteType
[]))]; }
1724 { int arr
[F(__has_trivial_copy(AnIncompleteType
[]))]; } // expected-error {{incomplete type}}
1725 { int arr
[F(__has_trivial_copy(HasCopy
))]; }
1726 { int arr
[F(__has_trivial_copy(HasTemplateCons
))]; }
1727 { int arr
[F(__has_trivial_copy(VirtAr
))]; }
1728 { int arr
[F(__has_trivial_copy(void))]; }
1729 { int arr
[F(__has_trivial_copy(cvoid
))]; }
1730 { int arr
[F(__has_trivial_copy(AllPrivate
))]; }
1731 { int arr
[F(__has_trivial_copy(ExtDefaulted
))]; }
1734 void has_trivial_copy_assignment() {
1735 { int arr
[T(__has_trivial_assign(Int
))]; }
1736 { int arr
[T(__has_trivial_assign(IntAr
))]; }
1737 { int arr
[T(__has_trivial_assign(Union
))]; }
1738 { int arr
[T(__has_trivial_assign(UnionAr
))]; }
1739 { int arr
[T(__has_trivial_assign(POD
))]; }
1740 { int arr
[T(__has_trivial_assign(Derives
))]; }
1741 { int arr
[T(__has_trivial_assign(HasDest
))]; }
1742 { int arr
[T(__has_trivial_assign(HasPriv
))]; }
1743 { int arr
[T(__has_trivial_assign(HasCons
))]; }
1744 { int arr
[T(__has_trivial_assign(HasRef
))]; }
1745 { int arr
[T(__has_trivial_assign(HasCopy
))]; }
1746 { int arr
[T(__has_trivial_assign(HasMove
))]; }
1747 { int arr
[T(__has_trivial_assign(HasMoveAssign
))]; }
1748 { int arr
[T(__has_trivial_assign(AllDefaulted
))]; }
1749 { int arr
[T(__has_trivial_assign(AllDeleted
))]; }
1750 { int arr
[T(__has_trivial_assign(DerivesAr
))]; }
1751 { int arr
[T(__has_trivial_assign(DerivesHasRef
))]; }
1752 { int arr
[T(__has_trivial_assign(ACompleteType
[]))]; }
1754 { int arr
[F(__has_trivial_assign(AnIncompleteType
[]))]; } // expected-error {{incomplete type}}
1755 { int arr
[F(__has_trivial_assign(IntRef
))]; }
1756 { int arr
[F(__has_trivial_assign(HasCopyAssign
))]; }
1757 { int arr
[F(__has_trivial_assign(const Int
))]; }
1758 { int arr
[F(__has_trivial_assign(ConstIntAr
))]; }
1759 { int arr
[F(__has_trivial_assign(ConstIntArAr
))]; }
1760 { int arr
[F(__has_trivial_assign(VirtAr
))]; }
1761 { int arr
[F(__has_trivial_assign(void))]; }
1762 { int arr
[F(__has_trivial_assign(cvoid
))]; }
1763 { int arr
[F(__has_trivial_assign(AllPrivate
))]; }
1764 { int arr
[F(__has_trivial_assign(ExtDefaulted
))]; }
1767 void has_trivial_destructor() {
1768 { int arr
[T(__has_trivial_destructor(Int
))]; }
1769 { int arr
[T(__has_trivial_destructor(IntAr
))]; }
1770 { int arr
[T(__has_trivial_destructor(Union
))]; }
1771 { int arr
[T(__has_trivial_destructor(UnionAr
))]; }
1772 { int arr
[T(__has_trivial_destructor(POD
))]; }
1773 { int arr
[T(__has_trivial_destructor(Derives
))]; }
1774 { int arr
[T(__has_trivial_destructor(ConstIntAr
))]; }
1775 { int arr
[T(__has_trivial_destructor(ConstIntArAr
))]; }
1776 { int arr
[T(__has_trivial_destructor(HasPriv
))]; }
1777 { int arr
[T(__has_trivial_destructor(HasCons
))]; }
1778 { int arr
[T(__has_trivial_destructor(HasRef
))]; }
1779 { int arr
[T(__has_trivial_destructor(HasCopy
))]; }
1780 { int arr
[T(__has_trivial_destructor(HasMove
))]; }
1781 { int arr
[T(__has_trivial_destructor(IntRef
))]; }
1782 { int arr
[T(__has_trivial_destructor(HasCopyAssign
))]; }
1783 { int arr
[T(__has_trivial_destructor(HasMoveAssign
))]; }
1784 { int arr
[T(__has_trivial_destructor(const Int
))]; }
1785 { int arr
[T(__has_trivial_destructor(DerivesAr
))]; }
1786 { int arr
[T(__has_trivial_destructor(VirtAr
))]; }
1787 { int arr
[T(__has_trivial_destructor(AllDefaulted
))]; }
1788 { int arr
[T(__has_trivial_destructor(AllDeleted
))]; }
1789 { int arr
[T(__has_trivial_destructor(DerivesHasRef
))]; }
1790 { int arr
[T(__has_trivial_destructor(ACompleteType
[]))]; }
1792 { int arr
[F(__has_trivial_destructor(HasDest
))]; }
1793 { int arr
[F(__has_trivial_destructor(AnIncompleteType
[]))]; } // expected-error {{incomplete type}}
1794 { int arr
[F(__has_trivial_destructor(void))]; }
1795 { int arr
[F(__has_trivial_destructor(cvoid
))]; }
1796 { int arr
[F(__has_trivial_destructor(AllPrivate
))]; }
1797 { int arr
[F(__has_trivial_destructor(ExtDefaulted
))]; }
1800 struct A
{ ~A() {} };
1801 template<typename
> struct B
: A
{ };
1804 { int arr
[F(__has_trivial_destructor(A
))]; }
1805 { int arr
[F(__has_trivial_destructor(B
<int>))]; }
1809 template <int> int operator=( int );
1810 int operator=(PR11110
);
1815 class UsingAssignBase
{
1817 UsingAssign
&operator=(const UsingAssign
&) throw();
1820 class UsingAssign
: public UsingAssignBase
{
1822 using UsingAssignBase::operator=;
1825 void has_nothrow_assign() {
1826 { int arr
[T(__has_nothrow_assign(Int
))]; }
1827 { int arr
[T(__has_nothrow_assign(IntAr
))]; }
1828 { int arr
[T(__has_nothrow_assign(Union
))]; }
1829 { int arr
[T(__has_nothrow_assign(UnionAr
))]; }
1830 { int arr
[T(__has_nothrow_assign(POD
))]; }
1831 { int arr
[T(__has_nothrow_assign(Derives
))]; }
1832 { int arr
[T(__has_nothrow_assign(HasDest
))]; }
1833 { int arr
[T(__has_nothrow_assign(HasPriv
))]; }
1834 { int arr
[T(__has_nothrow_assign(HasCons
))]; }
1835 { int arr
[T(__has_nothrow_assign(HasRef
))]; }
1836 { int arr
[T(__has_nothrow_assign(HasCopy
))]; }
1837 { int arr
[T(__has_nothrow_assign(HasMove
))]; }
1838 { int arr
[T(__has_nothrow_assign(HasMoveAssign
))]; }
1839 { int arr
[T(__has_nothrow_assign(HasNoThrowCopyAssign
))]; }
1840 { int arr
[T(__has_nothrow_assign(HasMultipleNoThrowCopyAssign
))]; }
1841 { int arr
[T(__has_nothrow_assign(HasVirtDest
))]; }
1842 { int arr
[T(__has_nothrow_assign(AllPrivate
))]; }
1843 { int arr
[T(__has_nothrow_assign(UsingAssign
))]; }
1844 { int arr
[T(__has_nothrow_assign(DerivesAr
))]; }
1845 { int arr
[T(__has_nothrow_assign(ACompleteType
[]))]; }
1847 { int arr
[F(__has_nothrow_assign(AnIncompleteType
[]))]; } // expected-error {{incomplete type}}
1848 { int arr
[F(__has_nothrow_assign(IntRef
))]; }
1849 { int arr
[F(__has_nothrow_assign(HasCopyAssign
))]; }
1850 { int arr
[F(__has_nothrow_assign(HasMultipleCopyAssign
))]; }
1851 { int arr
[F(__has_nothrow_assign(const Int
))]; }
1852 { int arr
[F(__has_nothrow_assign(ConstIntAr
))]; }
1853 { int arr
[F(__has_nothrow_assign(ConstIntArAr
))]; }
1854 { int arr
[F(__has_nothrow_assign(VirtAr
))]; }
1855 { int arr
[F(__has_nothrow_assign(void))]; }
1856 { int arr
[F(__has_nothrow_assign(cvoid
))]; }
1857 { int arr
[F(__has_nothrow_assign(PR11110
))]; }
1860 void has_nothrow_move_assign() {
1861 { int arr
[T(__has_nothrow_move_assign(Int
))]; }
1862 { int arr
[T(__has_nothrow_move_assign(Enum
))]; }
1863 { int arr
[T(__has_nothrow_move_assign(Int
*))]; }
1864 { int arr
[T(__has_nothrow_move_assign(Enum
POD::*))]; }
1865 { int arr
[T(__has_nothrow_move_assign(POD
))]; }
1866 { int arr
[T(__has_nothrow_move_assign(HasPriv
))]; }
1867 { int arr
[T(__has_nothrow_move_assign(HasNoThrowMoveAssign
))]; }
1868 { int arr
[T(__has_nothrow_move_assign(HasNoExceptNoThrowMoveAssign
))]; }
1869 { int arr
[T(__has_nothrow_move_assign(HasMemberNoThrowMoveAssign
))]; }
1870 { int arr
[T(__has_nothrow_move_assign(HasMemberNoExceptNoThrowMoveAssign
))]; }
1871 { int arr
[T(__has_nothrow_move_assign(AllDeleted
))]; }
1872 { int arr
[T(__has_nothrow_move_assign(ACompleteType
[]))]; }
1874 { int arr
[F(__has_nothrow_move_assign(AnIncompleteType
[]))]; } // expected-error {{incomplete type}}
1875 { int arr
[F(__has_nothrow_move_assign(HasThrowMoveAssign
))]; }
1876 { int arr
[F(__has_nothrow_move_assign(HasNoExceptFalseMoveAssign
))]; }
1877 { int arr
[F(__has_nothrow_move_assign(HasMemberThrowMoveAssign
))]; }
1878 { int arr
[F(__has_nothrow_move_assign(HasMemberNoExceptFalseMoveAssign
))]; }
1879 { int arr
[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyCtor
))]; }
1880 { int arr
[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyAssign
))]; }
1881 { int arr
[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToDtor
))]; }
1884 { int arr
[T(__is_nothrow_assignable(HasNoThrowMoveAssign
, HasNoThrowMoveAssign
))]; }
1885 { int arr
[F(__is_nothrow_assignable(HasThrowMoveAssign
, HasThrowMoveAssign
))]; }
1887 { int arr
[T(__is_assignable(HasNoThrowMoveAssign
, HasNoThrowMoveAssign
))]; }
1888 { int arr
[T(__is_assignable(HasThrowMoveAssign
, HasThrowMoveAssign
))]; }
1891 void has_trivial_move_assign() {
1892 // n3376 12.8 [class.copy]/25
1893 // A copy/move assignment operator for class X is trivial if it
1894 // is not user-provided, its declared parameter type is the same
1895 // as if it had been implicitly declared, and if:
1896 // - class X has no virtual functions (10.3) and no virtual base
1897 // classes (10.1), and
1898 // - the assignment operator selected to copy/move each direct
1899 // base class subobject is trivial, and
1900 // - for each non-static data member of X that is of class type
1901 // (or array thereof), the assignment operator
1902 // selected to copy/move that member is trivial;
1903 { int arr
[T(__has_trivial_move_assign(Int
))]; }
1904 { int arr
[T(__has_trivial_move_assign(HasStaticMemberMoveAssign
))]; }
1905 { int arr
[T(__has_trivial_move_assign(AllDeleted
))]; }
1906 { int arr
[T(__has_trivial_move_assign(ACompleteType
[]))]; }
1908 { int arr
[F(__has_trivial_move_assign(AnIncompleteType
[]))]; } // expected-error {{incomplete type}}
1909 { int arr
[F(__has_trivial_move_assign(HasVirt
))]; }
1910 { int arr
[F(__has_trivial_move_assign(DerivesVirt
))]; }
1911 { int arr
[F(__has_trivial_move_assign(HasMoveAssign
))]; }
1912 { int arr
[F(__has_trivial_move_assign(DerivesHasMoveAssign
))]; }
1913 { int arr
[F(__has_trivial_move_assign(HasMemberMoveAssign
))]; }
1914 { int arr
[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyCtor
))]; }
1915 { int arr
[F(__has_nothrow_move_assign(NoDefaultMoveAssignDueToUDCopyAssign
))]; }
1918 void has_nothrow_copy() {
1919 { int arr
[T(__has_nothrow_copy(Int
))]; }
1920 { int arr
[T(__has_nothrow_copy(IntAr
))]; }
1921 { int arr
[T(__has_nothrow_copy(Union
))]; }
1922 { int arr
[T(__has_nothrow_copy(UnionAr
))]; }
1923 { int arr
[T(__has_nothrow_copy(POD
))]; }
1924 { int arr
[T(__has_nothrow_copy(const Int
))]; }
1925 { int arr
[T(__has_nothrow_copy(ConstIntAr
))]; }
1926 { int arr
[T(__has_nothrow_copy(ConstIntArAr
))]; }
1927 { int arr
[T(__has_nothrow_copy(Derives
))]; }
1928 { int arr
[T(__has_nothrow_copy(IntRef
))]; }
1929 { int arr
[T(__has_nothrow_copy(HasDest
))]; }
1930 { int arr
[T(__has_nothrow_copy(HasPriv
))]; }
1931 { int arr
[T(__has_nothrow_copy(HasCons
))]; }
1932 { int arr
[T(__has_nothrow_copy(HasRef
))]; }
1933 { int arr
[T(__has_nothrow_copy(HasMove
))]; }
1934 { int arr
[T(__has_nothrow_copy(HasCopyAssign
))]; }
1935 { int arr
[T(__has_nothrow_copy(HasMoveAssign
))]; }
1936 { int arr
[T(__has_nothrow_copy(HasNoThrowCopy
))]; }
1937 { int arr
[T(__has_nothrow_copy(HasMultipleNoThrowCopy
))]; }
1938 { int arr
[T(__has_nothrow_copy(HasVirtDest
))]; }
1939 { int arr
[T(__has_nothrow_copy(HasTemplateCons
))]; }
1940 { int arr
[T(__has_nothrow_copy(AllPrivate
))]; }
1941 { int arr
[T(__has_nothrow_copy(DerivesAr
))]; }
1942 { int arr
[T(__has_nothrow_copy(ACompleteType
[]))]; }
1944 { int arr
[F(__has_nothrow_copy(AnIncompleteType
[]))]; } // expected-error {{incomplete type}}
1945 { int arr
[F(__has_nothrow_copy(HasCopy
))]; }
1946 { int arr
[F(__has_nothrow_copy(HasMultipleCopy
))]; }
1947 { int arr
[F(__has_nothrow_copy(VirtAr
))]; }
1948 { int arr
[F(__has_nothrow_copy(void))]; }
1949 { int arr
[F(__has_nothrow_copy(cvoid
))]; }
1952 void has_nothrow_constructor() {
1953 { int arr
[T(__has_nothrow_constructor(Int
))]; }
1954 { int arr
[T(__has_nothrow_constructor(IntAr
))]; }
1955 { int arr
[T(__has_nothrow_constructor(Union
))]; }
1956 { int arr
[T(__has_nothrow_constructor(UnionAr
))]; }
1957 { int arr
[T(__has_nothrow_constructor(POD
))]; }
1958 { int arr
[T(__has_nothrow_constructor(Derives
))]; }
1959 { int arr
[T(__has_nothrow_constructor(DerivesAr
))]; }
1960 { int arr
[T(__has_nothrow_constructor(ConstIntAr
))]; }
1961 { int arr
[T(__has_nothrow_constructor(ConstIntArAr
))]; }
1962 { int arr
[T(__has_nothrow_constructor(HasDest
))]; }
1963 { int arr
[T(__has_nothrow_constructor(HasPriv
))]; }
1964 { int arr
[T(__has_nothrow_constructor(HasCopyAssign
))]; }
1965 { int arr
[T(__has_nothrow_constructor(const Int
))]; }
1966 { int arr
[T(__has_nothrow_constructor(HasNoThrowConstructor
))]; }
1967 { int arr
[T(__has_nothrow_constructor(HasVirtDest
))]; }
1968 // { int arr[T(__has_nothrow_constructor(VirtAr))]; } // not implemented
1969 { int arr
[T(__has_nothrow_constructor(AllPrivate
))]; }
1970 { int arr
[T(__has_nothrow_constructor(ACompleteType
[]))]; }
1972 { int arr
[F(__has_nothrow_constructor(AnIncompleteType
[]))]; } // expected-error {{incomplete type}}
1973 { int arr
[F(__has_nothrow_constructor(HasCons
))]; }
1974 { int arr
[F(__has_nothrow_constructor(HasRef
))]; }
1975 { int arr
[F(__has_nothrow_constructor(HasCopy
))]; }
1976 { int arr
[F(__has_nothrow_constructor(HasMove
))]; }
1977 { int arr
[F(__has_nothrow_constructor(HasNoThrowConstructorWithArgs
))]; }
1978 { int arr
[F(__has_nothrow_constructor(IntRef
))]; }
1979 { int arr
[F(__has_nothrow_constructor(void))]; }
1980 { int arr
[F(__has_nothrow_constructor(cvoid
))]; }
1981 { int arr
[F(__has_nothrow_constructor(HasTemplateCons
))]; }
1983 { int arr
[F(__has_nothrow_constructor(HasMultipleDefaultConstructor1
))]; }
1984 { int arr
[F(__has_nothrow_constructor(HasMultipleDefaultConstructor2
))]; }
1987 void has_virtual_destructor() {
1988 { int arr
[F(__has_virtual_destructor(Int
))]; }
1989 { int arr
[F(__has_virtual_destructor(IntAr
))]; }
1990 { int arr
[F(__has_virtual_destructor(Union
))]; }
1991 { int arr
[F(__has_virtual_destructor(UnionAr
))]; }
1992 { int arr
[F(__has_virtual_destructor(POD
))]; }
1993 { int arr
[F(__has_virtual_destructor(Derives
))]; }
1994 { int arr
[F(__has_virtual_destructor(DerivesAr
))]; }
1995 { int arr
[F(__has_virtual_destructor(const Int
))]; }
1996 { int arr
[F(__has_virtual_destructor(ConstIntAr
))]; }
1997 { int arr
[F(__has_virtual_destructor(ConstIntArAr
))]; }
1998 { int arr
[F(__has_virtual_destructor(HasDest
))]; }
1999 { int arr
[F(__has_virtual_destructor(HasPriv
))]; }
2000 { int arr
[F(__has_virtual_destructor(HasCons
))]; }
2001 { int arr
[F(__has_virtual_destructor(HasRef
))]; }
2002 { int arr
[F(__has_virtual_destructor(HasCopy
))]; }
2003 { int arr
[F(__has_virtual_destructor(HasMove
))]; }
2004 { int arr
[F(__has_virtual_destructor(HasCopyAssign
))]; }
2005 { int arr
[F(__has_virtual_destructor(HasMoveAssign
))]; }
2006 { int arr
[F(__has_virtual_destructor(IntRef
))]; }
2007 { int arr
[F(__has_virtual_destructor(VirtAr
))]; }
2008 { int arr
[F(__has_virtual_destructor(ACompleteType
[]))]; }
2010 { int arr
[F(__has_virtual_destructor(AnIncompleteType
[]))]; } // expected-error {{incomplete type}}
2011 { int arr
[T(__has_virtual_destructor(HasVirtDest
))]; }
2012 { int arr
[T(__has_virtual_destructor(DerivedVirtDest
))]; }
2013 { int arr
[F(__has_virtual_destructor(VirtDestAr
))]; }
2014 { int arr
[F(__has_virtual_destructor(void))]; }
2015 { int arr
[F(__has_virtual_destructor(cvoid
))]; }
2016 { int arr
[F(__has_virtual_destructor(AllPrivate
))]; }
2021 class Derived
: Base
{};
2022 class Derived2a
: Derived
{};
2023 class Derived2b
: Derived
{};
2024 class Derived3
: virtual Derived2a
, virtual Derived2b
{};
2025 template<typename T
> struct BaseA
{ T a
; };
2026 template<typename T
> struct DerivedB
: BaseA
<T
> { };
2027 template<typename T
> struct CrazyDerived
: T
{ };
2030 class class_forward
; // expected-note 2 {{forward declaration of 'class_forward'}}
2032 template <typename Base
, typename Derived
>
2034 int t
[T(__is_base_of(Base
, Derived
))];
2036 template <typename Base
, typename Derived
>
2038 int t
[F(__is_base_of(Base
, Derived
))];
2041 template <class T
> class DerivedTemp
: Base
{};
2042 template <class T
> class NonderivedTemp
{};
2043 template <class T
> class UndefinedTemp
; // expected-note {{declared here}}
2046 { int arr
[T(__is_base_of(Base
, Derived
))]; }
2047 { int arr
[T(__is_base_of(const Base
, Derived
))]; }
2048 { int arr
[F(__is_base_of(Derived
, Base
))]; }
2049 { int arr
[F(__is_base_of(Derived
, int))]; }
2050 { int arr
[T(__is_base_of(Base
, Base
))]; }
2051 { int arr
[T(__is_base_of(Base
, Derived3
))]; }
2052 { int arr
[T(__is_base_of(Derived
, Derived3
))]; }
2053 { int arr
[T(__is_base_of(Derived2b
, Derived3
))]; }
2054 { int arr
[T(__is_base_of(Derived2a
, Derived3
))]; }
2055 { int arr
[T(__is_base_of(BaseA
<int>, DerivedB
<int>))]; }
2056 { int arr
[F(__is_base_of(DerivedB
<int>, BaseA
<int>))]; }
2057 { int arr
[T(__is_base_of(Base
, CrazyDerived
<Base
>))]; }
2058 { int arr
[F(__is_base_of(Union
, Union
))]; }
2059 { int arr
[T(__is_base_of(Empty
, Empty
))]; }
2060 { int arr
[T(__is_base_of(class_forward
, class_forward
))]; }
2061 { int arr
[F(__is_base_of(Empty
, class_forward
))]; } // expected-error {{incomplete type 'class_forward' used in type trait expression}}
2062 { int arr
[F(__is_base_of(Base
&, Derived
&))]; }
2063 int t18
[F(__is_base_of(Base
[10], Derived
[10]))];
2064 { int arr
[F(__is_base_of(int, int))]; }
2065 { int arr
[F(__is_base_of(long, int))]; }
2066 { int arr
[T(__is_base_of(Base
, DerivedTemp
<int>))]; }
2067 { int arr
[F(__is_base_of(Base
, NonderivedTemp
<int>))]; }
2068 { int arr
[F(__is_base_of(Base
, UndefinedTemp
<int>))]; } // expected-error {{implicit instantiation of undefined template 'UndefinedTemp<int>'}}
2070 { int arr
[F(__is_base_of(IncompleteUnion
, IncompleteUnion
))]; }
2071 { int arr
[F(__is_base_of(Union
, IncompleteUnion
))]; }
2072 { int arr
[F(__is_base_of(IncompleteUnion
, Union
))]; }
2073 { int arr
[F(__is_base_of(IncompleteStruct
, IncompleteUnion
))]; }
2074 { int arr
[F(__is_base_of(IncompleteUnion
, IncompleteStruct
))]; }
2075 { int arr
[F(__is_base_of(Empty
, IncompleteUnion
))]; }
2076 { int arr
[F(__is_base_of(IncompleteUnion
, Empty
))]; }
2077 { int arr
[F(__is_base_of(int, IncompleteUnion
))]; }
2078 { int arr
[F(__is_base_of(IncompleteUnion
, int))]; }
2079 { int arr
[F(__is_base_of(Empty
, Union
))]; }
2080 { int arr
[F(__is_base_of(Union
, Empty
))]; }
2081 { int arr
[F(__is_base_of(int, Empty
))]; }
2082 { int arr
[F(__is_base_of(Union
, int))]; }
2084 isBaseOfT
<Base
, Derived
>();
2085 isBaseOfF
<Derived
, Base
>();
2087 isBaseOfT
<Base
, CrazyDerived
<Base
> >();
2088 isBaseOfF
<CrazyDerived
<Base
>, Base
>();
2090 isBaseOfT
<BaseA
<int>, DerivedB
<int> >();
2091 isBaseOfF
<DerivedB
<int>, BaseA
<int> >();
2094 template<class T
, class U
>
2095 class TemplateClass
{};
2098 using TemplateAlias
= TemplateClass
<T
, int>;
2100 typedef class Base BaseTypedef
;
2104 int t01
[T(__is_same(Base
, Base
))];
2105 int t02
[T(__is_same(Base
, BaseTypedef
))];
2106 int t03
[T(__is_same(TemplateClass
<int, int>, TemplateAlias
<int>))];
2108 int t10
[F(__is_same(Base
, const Base
))];
2109 int t11
[F(__is_same(Base
, Base
&))];
2110 int t12
[F(__is_same(Base
, Derived
))];
2112 // __is_same_as is a GCC compatibility synonym for __is_same.
2113 int t20
[T(__is_same_as(int, int))];
2114 int t21
[F(__is_same_as(int, float))];
2120 IntWrapper(int _value
) : value(_value
) {}
2121 operator int() const {
2129 FloatWrapper(float _value
) : value(_value
) {}
2130 FloatWrapper(const IntWrapper
& obj
)
2131 : value(static_cast<float>(obj
.value
)) {}
2132 operator float() const {
2135 operator IntWrapper() const {
2136 return IntWrapper(static_cast<int>(value
));
2140 void is_convertible()
2142 int t01
[T(__is_convertible(IntWrapper
, IntWrapper
))];
2143 int t02
[T(__is_convertible(IntWrapper
, const IntWrapper
))];
2144 int t03
[T(__is_convertible(IntWrapper
, int))];
2145 int t04
[T(__is_convertible(int, IntWrapper
))];
2146 int t05
[T(__is_convertible(IntWrapper
, FloatWrapper
))];
2147 int t06
[T(__is_convertible(FloatWrapper
, IntWrapper
))];
2148 int t07
[T(__is_convertible(FloatWrapper
, float))];
2149 int t08
[T(__is_convertible(float, FloatWrapper
))];
2152 struct FromInt
{ FromInt(int); };
2153 struct ToInt
{ operator int(); };
2154 typedef void Function();
2156 void is_convertible_to();
2158 PrivateCopy(const PrivateCopy
&);
2159 friend void is_convertible_to();
2162 template<typename T
>
2164 template<typename U
> X0(const X0
<U
>&);
2167 struct Abstract
{ virtual void f() = 0; };
2169 void is_convertible_to() {
2170 { int arr
[T(__is_convertible_to(Int
, Int
))]; }
2171 { int arr
[F(__is_convertible_to(Int
, IntAr
))]; }
2172 { int arr
[F(__is_convertible_to(IntAr
, IntAr
))]; }
2173 { int arr
[T(__is_convertible_to(void, void))]; }
2174 { int arr
[T(__is_convertible_to(cvoid
, void))]; }
2175 { int arr
[T(__is_convertible_to(void, cvoid
))]; }
2176 { int arr
[T(__is_convertible_to(cvoid
, cvoid
))]; }
2177 { int arr
[T(__is_convertible_to(int, FromInt
))]; }
2178 { int arr
[T(__is_convertible_to(long, FromInt
))]; }
2179 { int arr
[T(__is_convertible_to(double, FromInt
))]; }
2180 { int arr
[T(__is_convertible_to(const int, FromInt
))]; }
2181 { int arr
[T(__is_convertible_to(const int&, FromInt
))]; }
2182 { int arr
[T(__is_convertible_to(ToInt
, int))]; }
2183 { int arr
[T(__is_convertible_to(ToInt
, const int&))]; }
2184 { int arr
[T(__is_convertible_to(ToInt
, long))]; }
2185 { int arr
[F(__is_convertible_to(ToInt
, int&))]; }
2186 { int arr
[F(__is_convertible_to(ToInt
, FromInt
))]; }
2187 { int arr
[T(__is_convertible_to(IntAr
&, IntAr
&))]; }
2188 { int arr
[T(__is_convertible_to(IntAr
&, const IntAr
&))]; }
2189 { int arr
[F(__is_convertible_to(const IntAr
&, IntAr
&))]; }
2190 { int arr
[F(__is_convertible_to(Function
, Function
))]; }
2191 { int arr
[F(__is_convertible_to(PrivateCopy
, PrivateCopy
))]; }
2192 { int arr
[T(__is_convertible_to(X0
<int>, X0
<float>))]; }
2193 { int arr
[F(__is_convertible_to(Abstract
, Abstract
))]; }
2196 namespace is_convertible_to_instantiate
{
2197 // Make sure we don't try to instantiate the constructor.
2198 template<int x
> class A
{ A(int) { int a
[x
]; } };
2199 int x
= __is_convertible_to(int, A
<-1>);
2204 { int arr
[T(__is_trivial(int))]; }
2205 { int arr
[T(__is_trivial(Enum
))]; }
2206 { int arr
[T(__is_trivial(POD
))]; }
2207 { int arr
[T(__is_trivial(Int
))]; }
2208 { int arr
[T(__is_trivial(IntAr
))]; }
2209 { int arr
[T(__is_trivial(IntArNB
))]; }
2210 { int arr
[T(__is_trivial(Statics
))]; }
2211 { int arr
[T(__is_trivial(Empty
))]; }
2212 { int arr
[T(__is_trivial(EmptyUnion
))]; }
2213 { int arr
[T(__is_trivial(Union
))]; }
2214 { int arr
[T(__is_trivial(Derives
))]; }
2215 { int arr
[T(__is_trivial(DerivesAr
))]; }
2216 { int arr
[T(__is_trivial(DerivesArNB
))]; }
2217 { int arr
[T(__is_trivial(DerivesEmpty
))]; }
2218 { int arr
[T(__is_trivial(HasFunc
))]; }
2219 { int arr
[T(__is_trivial(HasOp
))]; }
2220 { int arr
[T(__is_trivial(HasConv
))]; }
2221 { int arr
[T(__is_trivial(HasAssign
))]; }
2222 { int arr
[T(__is_trivial(HasAnonymousUnion
))]; }
2223 { int arr
[T(__is_trivial(HasPriv
))]; }
2224 { int arr
[T(__is_trivial(HasProt
))]; }
2225 { int arr
[T(__is_trivial(DerivesHasPriv
))]; }
2226 { int arr
[T(__is_trivial(DerivesHasProt
))]; }
2227 { int arr
[T(__is_trivial(Vector
))]; }
2228 { int arr
[T(__is_trivial(VectorExt
))]; }
2230 { int arr
[F(__is_trivial(HasCons
))]; }
2231 { int arr
[F(__is_trivial(HasCopyAssign
))]; }
2232 { int arr
[F(__is_trivial(HasMoveAssign
))]; }
2233 { int arr
[F(__is_trivial(HasDest
))]; }
2234 { int arr
[F(__is_trivial(HasRef
))]; }
2235 { int arr
[F(__is_trivial(HasNonPOD
))]; }
2236 { int arr
[F(__is_trivial(HasVirt
))]; }
2237 { int arr
[F(__is_trivial(DerivesHasCons
))]; }
2238 { int arr
[F(__is_trivial(DerivesHasCopyAssign
))]; }
2239 { int arr
[F(__is_trivial(DerivesHasMoveAssign
))]; }
2240 { int arr
[F(__is_trivial(DerivesHasDest
))]; }
2241 { int arr
[F(__is_trivial(DerivesHasRef
))]; }
2242 { int arr
[F(__is_trivial(DerivesHasVirt
))]; }
2243 { int arr
[F(__is_trivial(void))]; }
2244 { int arr
[F(__is_trivial(cvoid
))]; }
2247 template<typename T
> struct TriviallyConstructibleTemplate
{};
2249 void trivial_checks()
2251 { int arr
[T(__is_trivially_copyable(int))]; }
2252 { int arr
[T(__is_trivially_copyable(Enum
))]; }
2253 { int arr
[T(__is_trivially_copyable(POD
))]; }
2254 { int arr
[T(__is_trivially_copyable(Int
))]; }
2255 { int arr
[T(__is_trivially_copyable(IntAr
))]; }
2256 { int arr
[T(__is_trivially_copyable(IntArNB
))]; }
2257 { int arr
[T(__is_trivially_copyable(Statics
))]; }
2258 { int arr
[T(__is_trivially_copyable(Empty
))]; }
2259 { int arr
[T(__is_trivially_copyable(EmptyUnion
))]; }
2260 { int arr
[T(__is_trivially_copyable(Union
))]; }
2261 { int arr
[T(__is_trivially_copyable(Derives
))]; }
2262 { int arr
[T(__is_trivially_copyable(DerivesAr
))]; }
2263 { int arr
[T(__is_trivially_copyable(DerivesArNB
))]; }
2264 { int arr
[T(__is_trivially_copyable(DerivesEmpty
))]; }
2265 { int arr
[T(__is_trivially_copyable(HasFunc
))]; }
2266 { int arr
[T(__is_trivially_copyable(HasOp
))]; }
2267 { int arr
[T(__is_trivially_copyable(HasConv
))]; }
2268 { int arr
[T(__is_trivially_copyable(HasAssign
))]; }
2269 { int arr
[T(__is_trivially_copyable(HasAnonymousUnion
))]; }
2270 { int arr
[T(__is_trivially_copyable(HasPriv
))]; }
2271 { int arr
[T(__is_trivially_copyable(HasProt
))]; }
2272 { int arr
[T(__is_trivially_copyable(DerivesHasPriv
))]; }
2273 { int arr
[T(__is_trivially_copyable(DerivesHasProt
))]; }
2274 { int arr
[T(__is_trivially_copyable(Vector
))]; }
2275 { int arr
[T(__is_trivially_copyable(VectorExt
))]; }
2276 { int arr
[T(__is_trivially_copyable(HasCons
))]; }
2277 { int arr
[T(__is_trivially_copyable(HasRef
))]; }
2278 { int arr
[T(__is_trivially_copyable(HasNonPOD
))]; }
2279 { int arr
[T(__is_trivially_copyable(DerivesHasCons
))]; }
2280 { int arr
[T(__is_trivially_copyable(DerivesHasRef
))]; }
2281 { int arr
[T(__is_trivially_copyable(NonTrivialDefault
))]; }
2282 { int arr
[T(__is_trivially_copyable(NonTrivialDefault
[]))]; }
2283 { int arr
[T(__is_trivially_copyable(NonTrivialDefault
[3]))]; }
2285 { int arr
[F(__is_trivially_copyable(HasCopyAssign
))]; }
2286 { int arr
[F(__is_trivially_copyable(HasMoveAssign
))]; }
2287 { int arr
[F(__is_trivially_copyable(HasDest
))]; }
2288 { int arr
[F(__is_trivially_copyable(HasVirt
))]; }
2289 { int arr
[F(__is_trivially_copyable(DerivesHasCopyAssign
))]; }
2290 { int arr
[F(__is_trivially_copyable(DerivesHasMoveAssign
))]; }
2291 { int arr
[F(__is_trivially_copyable(DerivesHasDest
))]; }
2292 { int arr
[F(__is_trivially_copyable(DerivesHasVirt
))]; }
2293 { int arr
[F(__is_trivially_copyable(void))]; }
2294 { int arr
[F(__is_trivially_copyable(cvoid
))]; }
2296 { int arr
[T((__is_trivially_constructible(int)))]; }
2297 { int arr
[T((__is_trivially_constructible(int, int)))]; }
2298 { int arr
[T((__is_trivially_constructible(int, float)))]; }
2299 { int arr
[T((__is_trivially_constructible(int, int&)))]; }
2300 { int arr
[T((__is_trivially_constructible(int, const int&)))]; }
2301 { int arr
[T((__is_trivially_constructible(int, int)))]; }
2302 { int arr
[T((__is_trivially_constructible(HasCopyAssign
, HasCopyAssign
)))]; }
2303 { int arr
[T((__is_trivially_constructible(HasCopyAssign
, const HasCopyAssign
&)))]; }
2304 { int arr
[T((__is_trivially_constructible(HasCopyAssign
, HasCopyAssign
&&)))]; }
2305 { int arr
[T((__is_trivially_constructible(HasCopyAssign
)))]; }
2306 { int arr
[T((__is_trivially_constructible(NonTrivialDefault
,
2307 const NonTrivialDefault
&)))]; }
2308 { int arr
[T((__is_trivially_constructible(NonTrivialDefault
,
2309 NonTrivialDefault
&&)))]; }
2310 { int arr
[T((__is_trivially_constructible(AllDefaulted
)))]; }
2311 { int arr
[T((__is_trivially_constructible(AllDefaulted
,
2312 const AllDefaulted
&)))]; }
2313 { int arr
[T((__is_trivially_constructible(AllDefaulted
,
2314 AllDefaulted
&&)))]; }
2316 { int arr
[F((__is_trivially_constructible(int, int*)))]; }
2317 { int arr
[F((__is_trivially_constructible(NonTrivialDefault
)))]; }
2318 { int arr
[F((__is_trivially_constructible(ThreeArgCtor
, int*, char*, int&)))]; }
2319 { int arr
[F((__is_trivially_constructible(AllDeleted
)))]; }
2320 { int arr
[F((__is_trivially_constructible(AllDeleted
,
2321 const AllDeleted
&)))]; }
2322 { int arr
[F((__is_trivially_constructible(AllDeleted
,
2323 AllDeleted
&&)))]; }
2324 { int arr
[F((__is_trivially_constructible(ExtDefaulted
)))]; }
2325 { int arr
[F((__is_trivially_constructible(ExtDefaulted
,
2326 const ExtDefaulted
&)))]; }
2327 { int arr
[F((__is_trivially_constructible(ExtDefaulted
,
2328 ExtDefaulted
&&)))]; }
2330 { int arr
[T((__is_trivially_constructible(TriviallyConstructibleTemplate
<int>)))]; }
2331 { int arr
[F((__is_trivially_constructible(class_forward
)))]; } // expected-error {{incomplete type 'class_forward' used in type trait expression}}
2332 { int arr
[F((__is_trivially_constructible(class_forward
[])))]; }
2333 { int arr
[F((__is_trivially_constructible(void)))]; }
2335 { int arr
[T((__is_trivially_assignable(int&, int)))]; }
2336 { int arr
[T((__is_trivially_assignable(int&, int&)))]; }
2337 { int arr
[T((__is_trivially_assignable(int&, int&&)))]; }
2338 { int arr
[T((__is_trivially_assignable(int&, const int&)))]; }
2339 { int arr
[T((__is_trivially_assignable(POD
&, POD
)))]; }
2340 { int arr
[T((__is_trivially_assignable(POD
&, POD
&)))]; }
2341 { int arr
[T((__is_trivially_assignable(POD
&, POD
&&)))]; }
2342 { int arr
[T((__is_trivially_assignable(POD
&, const POD
&)))]; }
2343 { int arr
[T((__is_trivially_assignable(int*&, int*)))]; }
2344 { int arr
[T((__is_trivially_assignable(AllDefaulted
,
2345 const AllDefaulted
&)))]; }
2346 { int arr
[T((__is_trivially_assignable(AllDefaulted
,
2347 AllDefaulted
&&)))]; }
2349 { int arr
[F((__is_trivially_assignable(int*&, float*)))]; }
2350 { int arr
[F((__is_trivially_assignable(HasCopyAssign
&, HasCopyAssign
)))]; }
2351 { int arr
[F((__is_trivially_assignable(HasCopyAssign
&, HasCopyAssign
&)))]; }
2352 { int arr
[F((__is_trivially_assignable(HasCopyAssign
&, const HasCopyAssign
&)))]; }
2353 { int arr
[F((__is_trivially_assignable(HasCopyAssign
&, HasCopyAssign
&&)))]; }
2354 { int arr
[F((__is_trivially_assignable(TrivialMoveButNotCopy
&,
2355 TrivialMoveButNotCopy
&)))]; }
2356 { int arr
[F((__is_trivially_assignable(TrivialMoveButNotCopy
&,
2357 const TrivialMoveButNotCopy
&)))]; }
2358 { int arr
[F((__is_trivially_assignable(AllDeleted
,
2359 const AllDeleted
&)))]; }
2360 { int arr
[F((__is_trivially_assignable(AllDeleted
,
2361 AllDeleted
&&)))]; }
2362 { int arr
[F((__is_trivially_assignable(ExtDefaulted
,
2363 const ExtDefaulted
&)))]; }
2364 { int arr
[F((__is_trivially_assignable(ExtDefaulted
,
2365 ExtDefaulted
&&)))]; }
2367 { int arr
[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign
&,
2368 HasDefaultTrivialCopyAssign
&)))]; }
2369 { int arr
[T((__is_trivially_assignable(HasDefaultTrivialCopyAssign
&,
2370 const HasDefaultTrivialCopyAssign
&)))]; }
2371 { int arr
[T((__is_trivially_assignable(TrivialMoveButNotCopy
&,
2372 TrivialMoveButNotCopy
)))]; }
2373 { int arr
[T((__is_trivially_assignable(TrivialMoveButNotCopy
&,
2374 TrivialMoveButNotCopy
&&)))]; }
2375 { int arr
[T((__is_trivially_assignable(int&, int)))]; }
2376 { int arr
[T((__is_trivially_assignable(int&, int&)))]; }
2377 { int arr
[T((__is_trivially_assignable(int&, int&&)))]; }
2378 { int arr
[T((__is_trivially_assignable(int&, const int&)))]; }
2379 { int arr
[T((__is_trivially_assignable(POD
&, POD
)))]; }
2380 { int arr
[T((__is_trivially_assignable(POD
&, POD
&)))]; }
2381 { int arr
[T((__is_trivially_assignable(POD
&, POD
&&)))]; }
2382 { int arr
[T((__is_trivially_assignable(POD
&, const POD
&)))]; }
2383 { int arr
[T((__is_trivially_assignable(int*&, int*)))]; }
2384 { int arr
[T((__is_trivially_assignable(AllDefaulted
,
2385 const AllDefaulted
&)))]; }
2386 { int arr
[T((__is_trivially_assignable(AllDefaulted
,
2387 AllDefaulted
&&)))]; }
2389 { int arr
[F((__is_assignable(int *&, float *)))]; }
2390 { int arr
[T((__is_assignable(HasCopyAssign
&, HasCopyAssign
)))]; }
2391 { int arr
[T((__is_assignable(HasCopyAssign
&, HasCopyAssign
&)))]; }
2392 { int arr
[T((__is_assignable(HasCopyAssign
&, const HasCopyAssign
&)))]; }
2393 { int arr
[T((__is_assignable(HasCopyAssign
&, HasCopyAssign
&&)))]; }
2394 { int arr
[T((__is_assignable(TrivialMoveButNotCopy
&,
2395 TrivialMoveButNotCopy
&)))]; }
2396 { int arr
[T((__is_assignable(TrivialMoveButNotCopy
&,
2397 const TrivialMoveButNotCopy
&)))]; }
2398 { int arr
[F((__is_assignable(AllDeleted
,
2399 const AllDeleted
&)))]; }
2400 { int arr
[F((__is_assignable(AllDeleted
,
2401 AllDeleted
&&)))]; }
2402 { int arr
[T((__is_assignable(ExtDefaulted
,
2403 const ExtDefaulted
&)))]; }
2404 { int arr
[T((__is_assignable(ExtDefaulted
,
2405 ExtDefaulted
&&)))]; }
2407 { int arr
[T((__is_assignable(HasDefaultTrivialCopyAssign
&,
2408 HasDefaultTrivialCopyAssign
&)))]; }
2409 { int arr
[T((__is_assignable(HasDefaultTrivialCopyAssign
&,
2410 const HasDefaultTrivialCopyAssign
&)))]; }
2411 { int arr
[T((__is_assignable(TrivialMoveButNotCopy
&,
2412 TrivialMoveButNotCopy
)))]; }
2413 { int arr
[T((__is_assignable(TrivialMoveButNotCopy
&,
2414 TrivialMoveButNotCopy
&&)))]; }
2416 { int arr
[T(__is_assignable(ACompleteType
, ACompleteType
))]; }
2417 { int arr
[F(__is_assignable(AnIncompleteType
, AnIncompleteType
))]; } // expected-error {{incomplete type}}
2418 { int arr
[F(__is_assignable(AnIncompleteType
[], AnIncompleteType
[]))]; }
2419 { int arr
[F(__is_assignable(AnIncompleteType
[1], AnIncompleteType
[1]))]; } // expected-error {{incomplete type}}
2420 { int arr
[F(__is_assignable(void, void))]; }
2421 { int arr
[F(__is_assignable(const volatile void, const volatile void))]; }
2424 void constructible_checks() {
2425 { int arr
[T(__is_constructible(HasNoThrowConstructorWithArgs
))]; }
2426 { int arr
[F(__is_nothrow_constructible(HasNoThrowConstructorWithArgs
))]; } // MSVC doesn't look into default args and gets this wrong.
2428 { int arr
[T(__is_constructible(HasNoThrowConstructorWithArgs
, HasCons
))]; }
2429 { int arr
[T(__is_nothrow_constructible(HasNoThrowConstructorWithArgs
, HasCons
))]; }
2431 { int arr
[T(__is_constructible(NonTrivialDefault
))]; }
2432 { int arr
[F(__is_nothrow_constructible(NonTrivialDefault
))]; }
2434 { int arr
[T(__is_constructible(int))]; }
2435 { int arr
[T(__is_nothrow_constructible(int))]; }
2437 { int arr
[F(__is_constructible(NonPOD
))]; }
2438 { int arr
[F(__is_nothrow_constructible(NonPOD
))]; }
2440 { int arr
[T(__is_constructible(NonPOD
, int))]; }
2441 { int arr
[F(__is_nothrow_constructible(NonPOD
, int))]; }
2444 { int arr
[F(__is_constructible(Abstract
))]; }
2445 { int arr
[F(__is_nothrow_constructible(Abstract
))]; }
2448 { int arr
[T(__is_constructible(VariadicCtor
,
2449 int, int, int, int, int, int, int, int, int))]; }
2452 { int arr
[F(__is_constructible(int(int)))]; }
2453 { int arr
[T(__is_constructible(int const &, long))]; }
2455 { int arr
[T(__is_constructible(ACompleteType
))]; }
2456 { int arr
[T(__is_nothrow_constructible(ACompleteType
))]; }
2457 { int arr
[F(__is_constructible(AnIncompleteType
))]; } // expected-error {{incomplete type}}
2458 { int arr
[F(__is_nothrow_constructible(AnIncompleteType
))]; } // expected-error {{incomplete type}}
2459 { int arr
[F(__is_constructible(AnIncompleteType
[]))]; }
2460 { int arr
[F(__is_nothrow_constructible(AnIncompleteType
[]))]; }
2461 { int arr
[F(__is_constructible(AnIncompleteType
[1]))]; } // expected-error {{incomplete type}}
2462 { int arr
[F(__is_nothrow_constructible(AnIncompleteType
[1]))]; } // expected-error {{incomplete type}}
2463 { int arr
[F(__is_constructible(void))]; }
2464 { int arr
[F(__is_nothrow_constructible(void))]; }
2465 { int arr
[F(__is_constructible(const volatile void))]; }
2466 { int arr
[F(__is_nothrow_constructible(const volatile void))]; }
2469 // Instantiation of __is_trivially_constructible
2470 template<typename T
, typename
...Args
>
2471 struct is_trivially_constructible
{
2472 static const bool value
= __is_trivially_constructible(T
, Args
...);
2475 void is_trivially_constructible_test() {
2476 { int arr
[T((is_trivially_constructible
<int>::value
))]; }
2477 { int arr
[T((is_trivially_constructible
<int, int>::value
))]; }
2478 { int arr
[T((is_trivially_constructible
<int, float>::value
))]; }
2479 { int arr
[T((is_trivially_constructible
<int, int&>::value
))]; }
2480 { int arr
[T((is_trivially_constructible
<int, const int&>::value
))]; }
2481 { int arr
[T((is_trivially_constructible
<int, int>::value
))]; }
2482 { int arr
[T((is_trivially_constructible
<HasCopyAssign
, HasCopyAssign
>::value
))]; }
2483 { int arr
[T((is_trivially_constructible
<HasCopyAssign
, const HasCopyAssign
&>::value
))]; }
2484 { int arr
[T((is_trivially_constructible
<HasCopyAssign
, HasCopyAssign
&&>::value
))]; }
2485 { int arr
[T((is_trivially_constructible
<HasCopyAssign
>::value
))]; }
2486 { int arr
[T((is_trivially_constructible
<NonTrivialDefault
,
2487 const NonTrivialDefault
&>::value
))]; }
2488 { int arr
[T((is_trivially_constructible
<NonTrivialDefault
,
2489 NonTrivialDefault
&&>::value
))]; }
2491 { int arr
[F((is_trivially_constructible
<int, int*>::value
))]; }
2492 { int arr
[F((is_trivially_constructible
<NonTrivialDefault
>::value
))]; }
2493 { int arr
[F((is_trivially_constructible
<ThreeArgCtor
, int*, char*, int&>::value
))]; }
2494 { int arr
[F((is_trivially_constructible
<Abstract
>::value
))]; } // PR19178
2496 { int arr
[T(__is_trivially_constructible(ACompleteType
))]; }
2497 { int arr
[F(__is_trivially_constructible(AnIncompleteType
))]; } // expected-error {{incomplete type}}
2498 { int arr
[F(__is_trivially_constructible(AnIncompleteType
[]))]; }
2499 { int arr
[F(__is_trivially_constructible(AnIncompleteType
[1]))]; } // expected-error {{incomplete type}}
2500 { int arr
[F(__is_trivially_constructible(void))]; }
2501 { int arr
[F(__is_trivially_constructible(const volatile void))]; }
2504 template <class T
, class RefType
= T
&>
2505 struct ConvertsToRef
{
2506 operator RefType() const { return static_cast<RefType
>(obj
); }
2510 void reference_binds_to_temporary_checks() {
2511 { int arr
[F((__reference_binds_to_temporary(int &, int &)))]; }
2512 { int arr
[F((__reference_binds_to_temporary(int &, int &&)))]; }
2514 { int arr
[F((__reference_binds_to_temporary(int const &, int &)))]; }
2515 { int arr
[F((__reference_binds_to_temporary(int const &, int const &)))]; }
2516 { int arr
[F((__reference_binds_to_temporary(int const &, int &&)))]; }
2518 { int arr
[F((__reference_binds_to_temporary(int &, long &)))]; } // doesn't construct
2519 { int arr
[T((__reference_binds_to_temporary(int const &, long &)))]; }
2520 { int arr
[T((__reference_binds_to_temporary(int const &, long &&)))]; }
2521 { int arr
[T((__reference_binds_to_temporary(int &&, long &)))]; }
2523 using LRef
= ConvertsToRef
<int, int &>;
2524 using RRef
= ConvertsToRef
<int, int &&>;
2525 using CLRef
= ConvertsToRef
<int, const int &>;
2526 using LongRef
= ConvertsToRef
<long, long &>;
2527 { int arr
[T((__is_constructible(int &, LRef
)))]; }
2528 { int arr
[F((__reference_binds_to_temporary(int &, LRef
)))]; }
2530 { int arr
[T((__is_constructible(int &&, RRef
)))]; }
2531 { int arr
[F((__reference_binds_to_temporary(int &&, RRef
)))]; }
2533 { int arr
[T((__is_constructible(int const &, CLRef
)))]; }
2534 { int arr
[F((__reference_binds_to_temporary(int &&, CLRef
)))]; }
2536 { int arr
[T((__is_constructible(int const &, LongRef
)))]; }
2537 { int arr
[T((__reference_binds_to_temporary(int const &, LongRef
)))]; }
2539 // Test that it doesn't accept non-reference types as input.
2540 { int arr
[F((__reference_binds_to_temporary(int, long)))]; }
2542 { int arr
[T((__reference_binds_to_temporary(const int &, long)))]; }
2545 void reference_constructs_from_temporary_checks() {
2546 static_assert(!__reference_constructs_from_temporary(int &, int &), "");
2547 static_assert(!__reference_constructs_from_temporary(int &, int &&), "");
2549 static_assert(!__reference_constructs_from_temporary(int const &, int &), "");
2550 static_assert(!__reference_constructs_from_temporary(int const &, int const &), "");
2551 static_assert(!__reference_constructs_from_temporary(int const &, int &&), "");
2553 static_assert(!__reference_constructs_from_temporary(int &, long &), ""); // doesn't construct
2555 static_assert(__reference_constructs_from_temporary(int const &, long &), "");
2556 static_assert(__reference_constructs_from_temporary(int const &, long &&), "");
2557 static_assert(__reference_constructs_from_temporary(int &&, long &), "");
2559 using LRef
= ConvertsToRef
<int, int &>;
2560 using RRef
= ConvertsToRef
<int, int &&>;
2561 using CLRef
= ConvertsToRef
<int, const int &>;
2562 using LongRef
= ConvertsToRef
<long, long &>;
2563 static_assert(__is_constructible(int &, LRef
), "");
2564 static_assert(!__reference_constructs_from_temporary(int &, LRef
), "");
2566 static_assert(__is_constructible(int &&, RRef
), "");
2567 static_assert(!__reference_constructs_from_temporary(int &&, RRef
), "");
2569 static_assert(__is_constructible(int const &, CLRef
), "");
2570 static_assert(!__reference_constructs_from_temporary(int &&, CLRef
), "");
2572 static_assert(__is_constructible(int const &, LongRef
), "");
2573 static_assert(__reference_constructs_from_temporary(int const &, LongRef
), "");
2575 // Test that it doesn't accept non-reference types as input.
2576 static_assert(!__reference_constructs_from_temporary(int, long), "");
2578 static_assert(__reference_constructs_from_temporary(const int &, long), "");
2580 // Additional checks
2581 static_assert(__reference_constructs_from_temporary(POD
const&, Derives
), "");
2582 static_assert(__reference_constructs_from_temporary(int&&, int), "");
2583 static_assert(__reference_constructs_from_temporary(const int&, int), "");
2584 static_assert(!__reference_constructs_from_temporary(int&&, int&&), "");
2585 static_assert(!__reference_constructs_from_temporary(const int&, int&&), "");
2586 static_assert(__reference_constructs_from_temporary(int&&, long&&), "");
2587 static_assert(__reference_constructs_from_temporary(int&&, long), "");
2591 int t01
[T(__array_rank(IntAr
) == 1)];
2592 int t02
[T(__array_rank(ConstIntArAr
) == 2)];
2595 void array_extent() {
2596 int t01
[T(__array_extent(IntAr
, 0) == 10)];
2597 int t02
[T(__array_extent(ConstIntArAr
, 0) == 4)];
2598 int t03
[T(__array_extent(ConstIntArAr
, 1) == 10)];
2601 void is_destructible_test() {
2602 { int arr
[T(__is_destructible(int))]; }
2603 { int arr
[T(__is_destructible(int[2]))]; }
2604 { int arr
[F(__is_destructible(int[]))]; }
2605 { int arr
[F(__is_destructible(void))]; }
2606 { int arr
[T(__is_destructible(int &))]; }
2607 { int arr
[T(__is_destructible(HasDest
))]; }
2608 { int arr
[F(__is_destructible(AllPrivate
))]; }
2609 { int arr
[T(__is_destructible(SuperNonTrivialStruct
))]; }
2610 { int arr
[T(__is_destructible(AllDefaulted
))]; }
2611 { int arr
[F(__is_destructible(AllDeleted
))]; }
2612 { int arr
[T(__is_destructible(ThrowingDtor
))]; }
2613 { int arr
[T(__is_destructible(NoThrowDtor
))]; }
2615 { int arr
[T(__is_destructible(ACompleteType
))]; }
2616 { int arr
[F(__is_destructible(AnIncompleteType
))]; } // expected-error {{incomplete type}}
2617 { int arr
[F(__is_destructible(AnIncompleteType
[]))]; }
2618 { int arr
[F(__is_destructible(AnIncompleteType
[1]))]; } // expected-error {{incomplete type}}
2619 { int arr
[F(__is_destructible(void))]; }
2620 { int arr
[F(__is_destructible(const volatile void))]; }
2623 void is_nothrow_destructible_test() {
2624 { int arr
[T(__is_nothrow_destructible(int))]; }
2625 { int arr
[T(__is_nothrow_destructible(int[2]))]; }
2626 { int arr
[F(__is_nothrow_destructible(int[]))]; }
2627 { int arr
[F(__is_nothrow_destructible(void))]; }
2628 { int arr
[T(__is_nothrow_destructible(int &))]; }
2629 { int arr
[T(__is_nothrow_destructible(HasDest
))]; }
2630 { int arr
[F(__is_nothrow_destructible(AllPrivate
))]; }
2631 { int arr
[T(__is_nothrow_destructible(SuperNonTrivialStruct
))]; }
2632 { int arr
[T(__is_nothrow_destructible(AllDefaulted
))]; }
2633 { int arr
[F(__is_nothrow_destructible(AllDeleted
))]; }
2634 { int arr
[F(__is_nothrow_destructible(ThrowingDtor
))]; }
2635 { int arr
[T(__is_nothrow_destructible(NoExceptDtor
))]; }
2636 { int arr
[T(__is_nothrow_destructible(NoThrowDtor
))]; }
2638 { int arr
[T(__is_nothrow_destructible(ACompleteType
))]; }
2639 { int arr
[F(__is_nothrow_destructible(AnIncompleteType
))]; } // expected-error {{incomplete type}}
2640 { int arr
[F(__is_nothrow_destructible(AnIncompleteType
[]))]; }
2641 { int arr
[F(__is_nothrow_destructible(AnIncompleteType
[1]))]; } // expected-error {{incomplete type}}
2642 { int arr
[F(__is_nothrow_destructible(void))]; }
2643 { int arr
[F(__is_nothrow_destructible(const volatile void))]; }
2646 void is_trivially_destructible_test() {
2647 { int arr
[T(__is_trivially_destructible(int))]; }
2648 { int arr
[T(__is_trivially_destructible(int[2]))]; }
2649 { int arr
[F(__is_trivially_destructible(int[]))]; }
2650 { int arr
[F(__is_trivially_destructible(void))]; }
2651 { int arr
[T(__is_trivially_destructible(int &))]; }
2652 { int arr
[F(__is_trivially_destructible(HasDest
))]; }
2653 { int arr
[F(__is_trivially_destructible(AllPrivate
))]; }
2654 { int arr
[F(__is_trivially_destructible(SuperNonTrivialStruct
))]; }
2655 { int arr
[T(__is_trivially_destructible(AllDefaulted
))]; }
2656 { int arr
[F(__is_trivially_destructible(AllDeleted
))]; }
2657 { int arr
[F(__is_trivially_destructible(ThrowingDtor
))]; }
2658 { int arr
[F(__is_trivially_destructible(NoThrowDtor
))]; }
2660 { int arr
[T(__is_trivially_destructible(ACompleteType
))]; }
2661 { int arr
[F(__is_trivially_destructible(AnIncompleteType
))]; } // expected-error {{incomplete type}}
2662 { int arr
[F(__is_trivially_destructible(AnIncompleteType
[]))]; }
2663 { int arr
[F(__is_trivially_destructible(AnIncompleteType
[1]))]; } // expected-error {{incomplete type}}
2664 { int arr
[F(__is_trivially_destructible(void))]; }
2665 { int arr
[F(__is_trivially_destructible(const volatile void))]; }
2668 // Instantiation of __has_unique_object_representations
2669 template <typename T
>
2670 struct has_unique_object_representations
{
2671 static const bool value
= __has_unique_object_representations(T
);
2674 static_assert(!has_unique_object_representations
<void>::value
, "void is never unique");
2675 static_assert(!has_unique_object_representations
<const void>::value
, "void is never unique");
2676 static_assert(!has_unique_object_representations
<volatile void>::value
, "void is never unique");
2677 static_assert(!has_unique_object_representations
<const volatile void>::value
, "void is never unique");
2679 static_assert(has_unique_object_representations
<int>::value
, "integrals are");
2680 static_assert(has_unique_object_representations
<const int>::value
, "integrals are");
2681 static_assert(has_unique_object_representations
<volatile int>::value
, "integrals are");
2682 static_assert(has_unique_object_representations
<const volatile int>::value
, "integrals are");
2684 static_assert(has_unique_object_representations
<void *>::value
, "as are pointers");
2685 static_assert(has_unique_object_representations
<const void *>::value
, "as are pointers");
2686 static_assert(has_unique_object_representations
<volatile void *>::value
, "are pointers");
2687 static_assert(has_unique_object_representations
<const volatile void *>::value
, "as are pointers");
2689 static_assert(has_unique_object_representations
<int *>::value
, "as are pointers");
2690 static_assert(has_unique_object_representations
<const int *>::value
, "as are pointers");
2691 static_assert(has_unique_object_representations
<volatile int *>::value
, "as are pointers");
2692 static_assert(has_unique_object_representations
<const volatile int *>::value
, "as are pointers");
2695 using FP
= int (*)(int);
2696 using PMF
= int (C::*)(int);
2697 using PMD
= int C::*;
2699 static_assert(has_unique_object_representations
<FP
>::value
, "even function pointers");
2700 static_assert(has_unique_object_representations
<const FP
>::value
, "even function pointers");
2701 static_assert(has_unique_object_representations
<volatile FP
>::value
, "even function pointers");
2702 static_assert(has_unique_object_representations
<const volatile FP
>::value
, "even function pointers");
2704 static_assert(has_unique_object_representations
<PMF
>::value
, "and pointer to members");
2705 static_assert(has_unique_object_representations
<const PMF
>::value
, "and pointer to members");
2706 static_assert(has_unique_object_representations
<volatile PMF
>::value
, "and pointer to members");
2707 static_assert(has_unique_object_representations
<const volatile PMF
>::value
, "and pointer to members");
2709 static_assert(has_unique_object_representations
<PMD
>::value
, "and pointer to members");
2710 static_assert(has_unique_object_representations
<const PMD
>::value
, "and pointer to members");
2711 static_assert(has_unique_object_representations
<volatile PMD
>::value
, "and pointer to members");
2712 static_assert(has_unique_object_representations
<const volatile PMD
>::value
, "and pointer to members");
2714 static_assert(has_unique_object_representations
<bool>::value
, "yes, all integral types");
2715 static_assert(has_unique_object_representations
<char>::value
, "yes, all integral types");
2716 static_assert(has_unique_object_representations
<signed char>::value
, "yes, all integral types");
2717 static_assert(has_unique_object_representations
<unsigned char>::value
, "yes, all integral types");
2718 static_assert(has_unique_object_representations
<short>::value
, "yes, all integral types");
2719 static_assert(has_unique_object_representations
<unsigned short>::value
, "yes, all integral types");
2720 static_assert(has_unique_object_representations
<int>::value
, "yes, all integral types");
2721 static_assert(has_unique_object_representations
<unsigned int>::value
, "yes, all integral types");
2722 static_assert(has_unique_object_representations
<long>::value
, "yes, all integral types");
2723 static_assert(has_unique_object_representations
<unsigned long>::value
, "yes, all integral types");
2724 static_assert(has_unique_object_representations
<long long>::value
, "yes, all integral types");
2725 static_assert(has_unique_object_representations
<unsigned long long>::value
, "yes, all integral types");
2726 static_assert(has_unique_object_representations
<wchar_t>::value
, "yes, all integral types");
2727 static_assert(has_unique_object_representations
<char16_t
>::value
, "yes, all integral types");
2728 static_assert(has_unique_object_representations
<char32_t
>::value
, "yes, all integral types");
2730 static_assert(!has_unique_object_representations
<void>::value
, "but not void!");
2731 static_assert(!has_unique_object_representations
<decltype(nullptr)>::value
, "or nullptr_t");
2732 static_assert(!has_unique_object_representations
<float>::value
, "definitely not Floating Point");
2733 static_assert(!has_unique_object_representations
<double>::value
, "definitely not Floating Point");
2734 static_assert(!has_unique_object_representations
<long double>::value
, "definitely not Floating Point");
2741 static_assert(has_unique_object_representations
<NoPadding
>::value
, "types without padding are");
2743 struct InheritsFromNoPadding
: NoPadding
{
2748 static_assert(has_unique_object_representations
<InheritsFromNoPadding
>::value
, "types without padding are");
2750 struct VirtuallyInheritsFromNoPadding
: virtual NoPadding
{
2755 static_assert(!has_unique_object_representations
<VirtuallyInheritsFromNoPadding
>::value
, "No virtual inheritance");
2762 //static_assert(!has_unique_object_representations<Padding>::value, "but not with padding");
2764 struct InheritsFromPadding
: Padding
{
2769 static_assert(!has_unique_object_representations
<InheritsFromPadding
>::value
, "or its subclasses");
2771 struct TailPadding
{
2776 static_assert(!has_unique_object_representations
<TailPadding
>::value
, "even at the end");
2782 static_assert(has_unique_object_representations
<TinyStruct
>::value
, "Should be no padding");
2784 struct InheritsFromTinyStruct
: TinyStruct
{
2788 static_assert(!has_unique_object_representations
<InheritsFromTinyStruct
>::value
, "Inherit causes padding");
2790 union NoPaddingUnion
{
2795 static_assert(has_unique_object_representations
<NoPaddingUnion
>::value
, "unions follow the same rules as structs");
2797 union PaddingUnion
{
2802 static_assert(!has_unique_object_representations
<PaddingUnion
>::value
, "unions follow the same rules as structs");
2804 struct NotTriviallyCopyable
{
2806 NotTriviallyCopyable(const NotTriviallyCopyable
&) {}
2809 static_assert(!has_unique_object_representations
<NotTriviallyCopyable
>::value
, "must be trivially copyable");
2811 struct HasNonUniqueMember
{
2815 static_assert(!has_unique_object_representations
<HasNonUniqueMember
>::value
, "all members must be unique");
2817 enum ExampleEnum
{ xExample
,
2819 enum LLEnum
: long long { xLongExample
,
2822 static_assert(has_unique_object_representations
<ExampleEnum
>::value
, "Enums are integrals, so unique!");
2823 static_assert(has_unique_object_representations
<LLEnum
>::value
, "Enums are integrals, so unique!");
2825 enum class ExampleEnumClass
{ xExample
,
2827 enum class LLEnumClass
: long long { xLongExample
,
2830 static_assert(has_unique_object_representations
<ExampleEnumClass
>::value
, "Enums are integrals, so unique!");
2831 static_assert(has_unique_object_representations
<LLEnumClass
>::value
, "Enums are integrals, so unique!");
2833 // because references aren't trivially copyable.
2834 static_assert(!has_unique_object_representations
<int &>::value
, "No references!");
2835 static_assert(!has_unique_object_representations
<const int &>::value
, "No references!");
2836 static_assert(!has_unique_object_representations
<volatile int &>::value
, "No references!");
2837 static_assert(!has_unique_object_representations
<const volatile int &>::value
, "No references!");
2838 static_assert(!has_unique_object_representations
<Empty
>::value
, "No empty types!");
2839 static_assert(!has_unique_object_representations
<EmptyUnion
>::value
, "No empty types!");
2841 class Compressed
: Empty
{
2845 static_assert(has_unique_object_representations
<Compressed
>::value
, "But inheriting from one is ok");
2847 class EmptyInheritor
: Compressed
{};
2849 static_assert(has_unique_object_representations
<EmptyInheritor
>::value
, "As long as the base has items, empty is ok");
2856 static_assert(!has_unique_object_representations
<Dynamic
>::value
, "Dynamic types are not valid");
2858 class InheritsDynamic
: Dynamic
{
2862 static_assert(!has_unique_object_representations
<InheritsDynamic
>::value
, "Dynamic types are not valid");
2864 static_assert(has_unique_object_representations
<int[42]>::value
, "Arrays are fine, as long as their value type is");
2865 static_assert(has_unique_object_representations
<int[]>::value
, "Arrays are fine, as long as their value type is");
2866 static_assert(has_unique_object_representations
<int[][42]>::value
, "Arrays are fine, as long as their value type is");
2867 static_assert(!has_unique_object_representations
<double[42]>::value
, "So no array of doubles!");
2868 static_assert(!has_unique_object_representations
<double[]>::value
, "So no array of doubles!");
2869 static_assert(!has_unique_object_representations
<double[][42]>::value
, "So no array of doubles!");
2871 struct __attribute__((aligned(16))) WeirdAlignment
{
2874 union __attribute__((aligned(16))) WeirdAlignmentUnion
{
2877 static_assert(!has_unique_object_representations
<WeirdAlignment
>::value
, "Alignment causes padding");
2878 static_assert(!has_unique_object_representations
<WeirdAlignmentUnion
>::value
, "Alignment causes padding");
2879 static_assert(!has_unique_object_representations
<WeirdAlignment
[42]>::value
, "Also no arrays that have padding");
2881 struct __attribute__((packed
)) PackedNoPadding1
{
2885 struct __attribute__((packed
)) PackedNoPadding2
{
2889 static_assert(has_unique_object_representations
<PackedNoPadding1
>::value
, "Packed structs have no padding");
2890 static_assert(has_unique_object_representations
<PackedNoPadding2
>::value
, "Packed structs have no padding");
2892 static_assert(!has_unique_object_representations
<int(int)>::value
, "Functions are not unique");
2893 static_assert(!has_unique_object_representations
<int(int) const>::value
, "Functions are not unique");
2894 static_assert(!has_unique_object_representations
<int(int) volatile>::value
, "Functions are not unique");
2895 static_assert(!has_unique_object_representations
<int(int) const volatile>::value
, "Functions are not unique");
2896 static_assert(!has_unique_object_representations
<int(int) &>::value
, "Functions are not unique");
2897 static_assert(!has_unique_object_representations
<int(int) const &>::value
, "Functions are not unique");
2898 static_assert(!has_unique_object_representations
<int(int) volatile &>::value
, "Functions are not unique");
2899 static_assert(!has_unique_object_representations
<int(int) const volatile &>::value
, "Functions are not unique");
2900 static_assert(!has_unique_object_representations
<int(int) &&>::value
, "Functions are not unique");
2901 static_assert(!has_unique_object_representations
<int(int) const &&>::value
, "Functions are not unique");
2902 static_assert(!has_unique_object_representations
<int(int) volatile &&>::value
, "Functions are not unique");
2903 static_assert(!has_unique_object_representations
<int(int) const volatile &&>::value
, "Functions are not unique");
2905 static_assert(!has_unique_object_representations
<int(int, ...)>::value
, "Functions are not unique");
2906 static_assert(!has_unique_object_representations
<int(int, ...) const>::value
, "Functions are not unique");
2907 static_assert(!has_unique_object_representations
<int(int, ...) volatile>::value
, "Functions are not unique");
2908 static_assert(!has_unique_object_representations
<int(int, ...) const volatile>::value
, "Functions are not unique");
2909 static_assert(!has_unique_object_representations
<int(int, ...) &>::value
, "Functions are not unique");
2910 static_assert(!has_unique_object_representations
<int(int, ...) const &>::value
, "Functions are not unique");
2911 static_assert(!has_unique_object_representations
<int(int, ...) volatile &>::value
, "Functions are not unique");
2912 static_assert(!has_unique_object_representations
<int(int, ...) const volatile &>::value
, "Functions are not unique");
2913 static_assert(!has_unique_object_representations
<int(int, ...) &&>::value
, "Functions are not unique");
2914 static_assert(!has_unique_object_representations
<int(int, ...) const &&>::value
, "Functions are not unique");
2915 static_assert(!has_unique_object_representations
<int(int, ...) volatile &&>::value
, "Functions are not unique");
2916 static_assert(!has_unique_object_representations
<int(int, ...) const volatile &&>::value
, "Functions are not unique");
2919 static auto lambda
= []() {};
2920 static_assert(!has_unique_object_representations
<decltype(lambda
)>::value
, "Lambdas follow struct rules");
2922 static auto lambda2
= [i
]() {};
2923 static_assert(has_unique_object_representations
<decltype(lambda2
)>::value
, "Lambdas follow struct rules");
2926 struct PaddedBitfield
{
2931 struct UnPaddedBitfield
{
2936 struct AlignedPaddedBitfield
{
2938 __attribute__((aligned(1)))
2942 struct UnnamedBitfield
{
2947 struct __attribute__((packed
)) UnnamedBitfieldPacked
{
2952 struct UnnamedEmptyBitfield
{
2957 struct UnnamedEmptyBitfieldSplit
{
2963 static_assert(!has_unique_object_representations
<PaddedBitfield
>::value
, "Bitfield padding");
2964 static_assert(has_unique_object_representations
<UnPaddedBitfield
>::value
, "Bitfield padding");
2965 static_assert(!has_unique_object_representations
<AlignedPaddedBitfield
>::value
, "Bitfield padding");
2966 static_assert(!has_unique_object_representations
<UnnamedBitfield
>::value
, "Bitfield padding");
2967 static_assert(!has_unique_object_representations
<UnnamedBitfieldPacked
>::value
, "Bitfield padding");
2968 static_assert(has_unique_object_representations
<UnnamedEmptyBitfield
>::value
, "Bitfield padding");
2969 static_assert(sizeof(UnnamedEmptyBitfieldSplit
) != (sizeof(short) * 2), "Wrong size");
2970 static_assert(!has_unique_object_representations
<UnnamedEmptyBitfieldSplit
>::value
, "Bitfield padding");
2972 struct BoolBitfield
{
2976 static_assert(has_unique_object_representations
<BoolBitfield
>::value
, "Bitfield bool");
2978 struct BoolBitfield2
{
2982 static_assert(!has_unique_object_representations
<BoolBitfield2
>::value
, "Bitfield bool");
2984 struct GreaterSizeBitfield
{
2985 //expected-warning@+1 {{width of bit-field 'n'}}
2989 static_assert(sizeof(GreaterSizeBitfield
) == 128, "Bitfield Size");
2990 static_assert(!has_unique_object_representations
<GreaterSizeBitfield
>::value
, "Bitfield padding");
2992 struct StructWithRef
{
2996 static_assert(has_unique_object_representations
<StructWithRef
>::value
, "References are still unique");
2998 struct NotUniqueBecauseTailPadding
{
3002 struct CanBeUniqueIfNoPadding
: NotUniqueBecauseTailPadding
{
3006 static_assert(!has_unique_object_representations
<NotUniqueBecauseTailPadding
>::value
,
3008 // Can be unique on Itanium, since the is child class' data is 'folded' into the
3009 // parent's tail padding.
3010 static_assert(sizeof(CanBeUniqueIfNoPadding
) != 16 ||
3011 has_unique_object_representations
<CanBeUniqueIfNoPadding
>::value
,
3012 "inherit from std layout");
3014 namespace ErrorType
{
3015 struct S
; //expected-note{{forward declaration of 'ErrorType::S'}}
3018 S t
; //expected-error{{field has incomplete type 'S'}}
3020 bool b
= __has_unique_object_representations(T
);
3023 static_assert(!has_unique_object_representations
<_BitInt(7)>::value
, "BitInt:");
3024 static_assert(has_unique_object_representations
<_BitInt(8)>::value
, "BitInt:");
3025 static_assert(!has_unique_object_representations
<_BitInt(127)>::value
, "BitInt:");
3026 static_assert(has_unique_object_representations
<_BitInt(128)>::value
, "BitInt:");
3030 // Foo has both a trivial assignment operator and a non-trivial one.
3032 Foo
&operator=(const Foo
&) & { return *this; }
3033 Foo
&operator=(const Foo
&) && = default;
3036 // Bar's copy assignment calls Foo's non-trivial assignment.
3041 static_assert(!__is_trivially_assignable(Foo
&, const Foo
&), "");
3042 static_assert(!__is_trivially_assignable(Bar
&, const Bar
&), "");
3044 // Foo2 has both a trivial assignment operator and a non-trivial one.
3046 Foo2
&operator=(const Foo2
&) & = default;
3047 Foo2
&operator=(const Foo2
&) && { return *this; }
3050 // Bar2's copy assignment calls Foo2's trivial assignment.
3055 static_assert(__is_trivially_assignable(Foo2
&, const Foo2
&), "");
3056 static_assert(__is_trivially_assignable(Bar2
&, const Bar2
&), "");
3059 namespace ConstClass
{
3061 A
&operator=(const A
&) = default;
3066 static_assert(!__is_trivially_assignable(B
&, const B
&), "");
3069 namespace type_trait_expr_numargs_overflow
{
3070 // Make sure that TypeTraitExpr can store 16 bits worth of arguments.
3071 #define T4(X) X,X,X,X
3072 #define T16(X) T4(X),T4(X),T4(X),T4(X)
3073 #define T64(X) T16(X),T16(X),T16(X),T16(X)
3074 #define T256(X) T64(X),T64(X),T64(X),T64(X)
3075 #define T1024(X) T256(X),T256(X),T256(X),T256(X)
3076 #define T4096(X) T1024(X),T1024(X),T1024(X),T1024(X)
3077 #define T16384(X) T4096(X),T4096(X),T4096(X),T4096(X)
3078 #define T32768(X) T16384(X),T16384(X)
3079 void test() { (void) __is_constructible(int, T32768(int)); }
3088 } // namespace type_trait_expr_numargs_overflow
3090 namespace is_trivially_relocatable
{
3092 static_assert(!__is_trivially_relocatable(void), "");
3093 static_assert(__is_trivially_relocatable(int), "");
3094 static_assert(__is_trivially_relocatable(int[]), "");
3097 static_assert(__is_trivially_relocatable(Enum
), "");
3098 static_assert(__is_trivially_relocatable(Enum
[]), "");
3100 union Union
{int x
;};
3101 static_assert(__is_trivially_relocatable(Union
), "");
3102 static_assert(__is_trivially_relocatable(Union
[]), "");
3105 static_assert(__is_trivially_relocatable(Trivial
), "");
3106 static_assert(__is_trivially_relocatable(Trivial
[]), "");
3108 struct Incomplete
; // expected-note {{forward declaration of 'is_trivially_relocatable::Incomplete'}}
3109 bool unused
= __is_trivially_relocatable(Incomplete
); // expected-error {{incomplete type}}
3111 struct NontrivialDtor
{
3112 ~NontrivialDtor() {}
3114 static_assert(!__is_trivially_relocatable(NontrivialDtor
), "");
3115 static_assert(!__is_trivially_relocatable(NontrivialDtor
[]), "");
3117 struct NontrivialCopyCtor
{
3118 NontrivialCopyCtor(const NontrivialCopyCtor
&) {}
3120 static_assert(!__is_trivially_relocatable(NontrivialCopyCtor
), "");
3121 static_assert(!__is_trivially_relocatable(NontrivialCopyCtor
[]), "");
3123 struct NontrivialMoveCtor
{
3124 NontrivialMoveCtor(NontrivialMoveCtor
&&) {}
3126 static_assert(!__is_trivially_relocatable(NontrivialMoveCtor
), "");
3127 static_assert(!__is_trivially_relocatable(NontrivialMoveCtor
[]), "");
3129 struct [[clang::trivial_abi
]] TrivialAbiNontrivialDtor
{
3130 ~TrivialAbiNontrivialDtor() {}
3132 static_assert(__is_trivially_relocatable(TrivialAbiNontrivialDtor
), "");
3133 static_assert(__is_trivially_relocatable(TrivialAbiNontrivialDtor
[]), "");
3135 struct [[clang::trivial_abi
]] TrivialAbiNontrivialCopyCtor
{
3136 TrivialAbiNontrivialCopyCtor(const TrivialAbiNontrivialCopyCtor
&) {}
3138 static_assert(__is_trivially_relocatable(TrivialAbiNontrivialCopyCtor
), "");
3139 static_assert(__is_trivially_relocatable(TrivialAbiNontrivialCopyCtor
[]), "");
3141 // A more complete set of tests for the behavior of trivial_abi can be found in
3142 // clang/test/SemaCXX/attr-trivial-abi.cpp
3143 struct [[clang::trivial_abi
]] TrivialAbiNontrivialMoveCtor
{
3144 TrivialAbiNontrivialMoveCtor(TrivialAbiNontrivialMoveCtor
&&) {}
3146 static_assert(__is_trivially_relocatable(TrivialAbiNontrivialMoveCtor
), "");
3147 static_assert(__is_trivially_relocatable(TrivialAbiNontrivialMoveCtor
[]), "");
3149 } // namespace is_trivially_relocatable
3151 namespace is_trivially_equality_comparable
{
3152 struct ForwardDeclared
; // expected-note {{forward declaration of 'is_trivially_equality_comparable::ForwardDeclared'}}
3153 static_assert(!__is_trivially_equality_comparable(ForwardDeclared
), ""); // expected-error {{incomplete type 'ForwardDeclared' used in type trait expression}}
3155 static_assert(!__is_trivially_equality_comparable(void), "");
3156 static_assert(__is_trivially_equality_comparable(int), "");
3157 static_assert(!__is_trivially_equality_comparable(int[]), "");
3158 static_assert(!__is_trivially_equality_comparable(int[3]), "");
3159 static_assert(!__is_trivially_equality_comparable(float), "");
3160 static_assert(!__is_trivially_equality_comparable(double), "");
3161 static_assert(!__is_trivially_equality_comparable(long double), "");
3163 struct NonTriviallyEqualityComparableNoComparator
{
3167 static_assert(!__is_trivially_equality_comparable(NonTriviallyEqualityComparableNoComparator
), "");
3169 struct NonTriviallyEqualityComparableNonDefaultedComparator
{
3172 bool operator==(const NonTriviallyEqualityComparableNonDefaultedComparator
&);
3174 static_assert(!__is_trivially_equality_comparable(NonTriviallyEqualityComparableNonDefaultedComparator
), "");
3176 #if __cplusplus >= 202002L
3178 struct TriviallyEqualityComparable
{
3183 bool operator==(int) const { return false; }
3185 bool operator==(const TriviallyEqualityComparable
&) const = default;
3187 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable
));
3189 struct TriviallyEqualityComparableContainsArray
{
3192 bool operator==(const TriviallyEqualityComparableContainsArray
&) const = default;
3194 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableContainsArray
));
3196 struct TriviallyEqualityComparableContainsMultiDimensionArray
{
3199 bool operator==(const TriviallyEqualityComparableContainsMultiDimensionArray
&) const = default;
3201 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableContainsMultiDimensionArray
));
3203 auto GetNonCapturingLambda() { return [](){ return 42; }; }
3205 struct TriviallyEqualityComparableContainsLambda
{
3206 [[no_unique_address
]] decltype(GetNonCapturingLambda()) l
;
3209 bool operator==(const TriviallyEqualityComparableContainsLambda
&) const = default;
3211 static_assert(!__is_trivially_equality_comparable(decltype(GetNonCapturingLambda()))); // padding
3212 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableContainsLambda
));
3214 struct TriviallyEqualityComparableNonTriviallyCopyable
{
3215 TriviallyEqualityComparableNonTriviallyCopyable(const TriviallyEqualityComparableNonTriviallyCopyable
&);
3216 ~TriviallyEqualityComparableNonTriviallyCopyable();
3217 bool operator==(const TriviallyEqualityComparableNonTriviallyCopyable
&) const = default;
3220 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableNonTriviallyCopyable
));
3222 struct NotTriviallyEqualityComparableHasPadding
{
3226 bool operator==(const NotTriviallyEqualityComparableHasPadding
&) const = default;
3228 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasPadding
), "");
3230 struct NotTriviallyEqualityComparableHasFloat
{
3234 bool operator==(const NotTriviallyEqualityComparableHasFloat
&) const = default;
3236 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasFloat
), "");
3238 struct NotTriviallyEqualityComparableHasTailPadding
{
3242 bool operator==(const NotTriviallyEqualityComparableHasTailPadding
&) const = default;
3244 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasTailPadding
), "");
3246 struct NotTriviallyEqualityComparableBase
: NotTriviallyEqualityComparableHasTailPadding
{
3249 bool operator==(const NotTriviallyEqualityComparableBase
&) const = default;
3251 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableBase
), "");
3253 class TriviallyEqualityComparablePaddedOutBase
{
3258 bool operator==(const TriviallyEqualityComparablePaddedOutBase
&) const = default;
3260 static_assert(!__is_trivially_equality_comparable(TriviallyEqualityComparablePaddedOutBase
), "");
3262 struct TriviallyEqualityComparablePaddedOut
: TriviallyEqualityComparablePaddedOutBase
{
3265 bool operator==(const TriviallyEqualityComparablePaddedOut
&) const = default;
3267 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparablePaddedOut
), "");
3269 struct TriviallyEqualityComparable1
{
3272 bool operator==(const TriviallyEqualityComparable1
&) const = default;
3274 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable1
));
3276 struct TriviallyEqualityComparable2
{
3279 bool operator==(const TriviallyEqualityComparable2
&) const = default;
3281 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable2
));
3283 struct NotTriviallyEqualityComparableTriviallyEqualityComparableBases
3284 : TriviallyEqualityComparable1
, TriviallyEqualityComparable2
{
3285 bool operator==(const NotTriviallyEqualityComparableTriviallyEqualityComparableBases
&) const = default;
3287 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableTriviallyEqualityComparableBases
));
3289 struct NotTriviallyEqualityComparableBitfield
{
3292 bool operator==(const NotTriviallyEqualityComparableBitfield
&) const = default;
3294 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableBitfield
));
3296 // TODO: This is trivially equality comparable
3297 struct NotTriviallyEqualityComparableBitfieldFilled
{
3298 char i
: __CHAR_BIT__
;
3300 bool operator==(const NotTriviallyEqualityComparableBitfieldFilled
&) const = default;
3302 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableBitfield
));
3307 bool operator==(const U
&) const = default;
3310 struct NotTriviallyEqualityComparableImplicitlyDeletedOperatorByUnion
{
3313 bool operator==(const NotTriviallyEqualityComparableImplicitlyDeletedOperatorByUnion
&) const = default;
3315 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableImplicitlyDeletedOperatorByUnion
));
3317 struct NotTriviallyEqualityComparableExplicitlyDeleted
{
3320 bool operator==(const NotTriviallyEqualityComparableExplicitlyDeleted
&) const = delete;
3323 struct NotTriviallyEqualityComparableImplicitlyDeletedOperatorByStruct
{
3324 NotTriviallyEqualityComparableExplicitlyDeleted u
;
3326 bool operator==(const NotTriviallyEqualityComparableImplicitlyDeletedOperatorByStruct
&) const = default;
3328 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableImplicitlyDeletedOperatorByStruct
));
3330 struct NotTriviallyEqualityComparableHasReferenceMember
{
3333 bool operator==(const NotTriviallyEqualityComparableHasReferenceMember
&) const = default;
3335 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasReferenceMember
));
3337 struct NotTriviallyEqualityComparableNonTriviallyComparableBaseBase
{
3340 bool operator==(const NotTriviallyEqualityComparableNonTriviallyComparableBaseBase
&) const {
3345 struct NotTriviallyEqualityComparableNonTriviallyComparableBase
: NotTriviallyEqualityComparableNonTriviallyComparableBaseBase
{
3348 bool operator==(const NotTriviallyEqualityComparableNonTriviallyComparableBase
&) const = default;
3350 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableNonTriviallyComparableBase
));
3356 bool operator==(E
, E
) { return false; }
3357 static_assert(!__is_trivially_equality_comparable(E
));
3359 struct NotTriviallyEqualityComparableHasEnum
{
3361 bool operator==(const NotTriviallyEqualityComparableHasEnum
&) const = default;
3363 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasEnum
));
3365 struct NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs
{
3368 bool operator==(const NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs
&) const = default;
3370 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs
));
3372 struct NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs2
{
3375 bool operator==(const NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs2
&) const = default;
3377 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableNonTriviallyEqualityComparableArrs2
));
3379 namespace hidden_friend
{
3381 struct TriviallyEqualityComparable
{
3386 bool operator==(int) const { return false; }
3388 friend bool operator==(const TriviallyEqualityComparable
&, const TriviallyEqualityComparable
&) = default;
3390 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable
), "");
3392 struct TriviallyEqualityComparableNonTriviallyCopyable
{
3393 TriviallyEqualityComparableNonTriviallyCopyable(const TriviallyEqualityComparableNonTriviallyCopyable
&);
3394 ~TriviallyEqualityComparableNonTriviallyCopyable();
3395 friend bool operator==(const TriviallyEqualityComparableNonTriviallyCopyable
&, const TriviallyEqualityComparableNonTriviallyCopyable
&) = default;
3398 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableNonTriviallyCopyable
));
3400 struct NotTriviallyEqualityComparableHasPadding
{
3404 friend bool operator==(const NotTriviallyEqualityComparableHasPadding
&, const NotTriviallyEqualityComparableHasPadding
&) = default;
3406 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasPadding
), "");
3408 struct NotTriviallyEqualityComparableHasFloat
{
3412 friend bool operator==(const NotTriviallyEqualityComparableHasFloat
&, const NotTriviallyEqualityComparableHasFloat
&) = default;
3414 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasFloat
), "");
3416 struct NotTriviallyEqualityComparableHasTailPadding
{
3420 friend bool operator==(const NotTriviallyEqualityComparableHasTailPadding
&, const NotTriviallyEqualityComparableHasTailPadding
&) = default;
3422 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasTailPadding
), "");
3424 struct NotTriviallyEqualityComparableBase
: NotTriviallyEqualityComparableHasTailPadding
{
3427 friend bool operator==(const NotTriviallyEqualityComparableBase
&, const NotTriviallyEqualityComparableBase
&) = default;
3429 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableBase
), "");
3431 class TriviallyEqualityComparablePaddedOutBase
{
3436 friend bool operator==(const TriviallyEqualityComparablePaddedOutBase
&, const TriviallyEqualityComparablePaddedOutBase
&) = default;
3438 static_assert(!__is_trivially_equality_comparable(TriviallyEqualityComparablePaddedOutBase
), "");
3440 struct TriviallyEqualityComparablePaddedOut
: TriviallyEqualityComparablePaddedOutBase
{
3443 friend bool operator==(const TriviallyEqualityComparablePaddedOut
&, const TriviallyEqualityComparablePaddedOut
&) = default;
3445 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparablePaddedOut
), "");
3447 struct TriviallyEqualityComparable1
{
3450 friend bool operator==(const TriviallyEqualityComparable1
&, const TriviallyEqualityComparable1
&) = default;
3452 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable1
));
3454 struct TriviallyEqualityComparable2
{
3457 friend bool operator==(const TriviallyEqualityComparable2
&, const TriviallyEqualityComparable2
&) = default;
3459 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparable2
));
3461 struct NotTriviallyEqualityComparableTriviallyEqualityComparableBases
3462 : TriviallyEqualityComparable1
, TriviallyEqualityComparable2
{
3463 friend bool operator==(const NotTriviallyEqualityComparableTriviallyEqualityComparableBases
&, const NotTriviallyEqualityComparableTriviallyEqualityComparableBases
&) = default;
3465 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableTriviallyEqualityComparableBases
));
3467 struct NotTriviallyEqualityComparableBitfield
{
3470 friend bool operator==(const NotTriviallyEqualityComparableBitfield
&, const NotTriviallyEqualityComparableBitfield
&) = default;
3472 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableBitfield
));
3474 // TODO: This is trivially equality comparable
3475 struct NotTriviallyEqualityComparableBitfieldFilled
{
3476 char i
: __CHAR_BIT__
;
3478 friend bool operator==(const NotTriviallyEqualityComparableBitfieldFilled
&, const NotTriviallyEqualityComparableBitfieldFilled
&) = default;
3480 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableBitfield
));
3485 friend bool operator==(const U
&, const U
&) = default;
3488 struct NotTriviallyEqualityComparableImplicitlyDeletedOperatorByUnion
{
3491 friend bool operator==(const NotTriviallyEqualityComparableImplicitlyDeletedOperatorByUnion
&, const NotTriviallyEqualityComparableImplicitlyDeletedOperatorByUnion
&) = default;
3493 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableImplicitlyDeletedOperatorByUnion
));
3495 struct NotTriviallyEqualityComparableExplicitlyDeleted
{
3498 friend bool operator==(const NotTriviallyEqualityComparableExplicitlyDeleted
&, const NotTriviallyEqualityComparableExplicitlyDeleted
&) = delete;
3501 struct NotTriviallyEqualityComparableImplicitlyDeletedOperatorByStruct
{
3502 NotTriviallyEqualityComparableExplicitlyDeleted u
;
3504 friend bool operator==(const NotTriviallyEqualityComparableImplicitlyDeletedOperatorByStruct
&, const NotTriviallyEqualityComparableImplicitlyDeletedOperatorByStruct
&) = default;
3506 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableImplicitlyDeletedOperatorByStruct
));
3508 struct NotTriviallyEqualityComparableHasReferenceMember
{
3511 friend bool operator==(const NotTriviallyEqualityComparableHasReferenceMember
&, const NotTriviallyEqualityComparableHasReferenceMember
&) = default;
3513 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasReferenceMember
));
3519 bool operator==(E
, E
) { return false; }
3520 static_assert(!__is_trivially_equality_comparable(E
));
3522 struct NotTriviallyEqualityComparableHasEnum
{
3524 friend bool operator==(const NotTriviallyEqualityComparableHasEnum
&, const NotTriviallyEqualityComparableHasEnum
&) = default;
3526 static_assert(!__is_trivially_equality_comparable(NotTriviallyEqualityComparableHasEnum
));
3528 struct NonTriviallyEqualityComparableValueComparisonNonTriviallyCopyable
{
3530 NonTriviallyEqualityComparableValueComparisonNonTriviallyCopyable(const NonTriviallyEqualityComparableValueComparisonNonTriviallyCopyable
&);
3532 friend bool operator==(NonTriviallyEqualityComparableValueComparisonNonTriviallyCopyable
, NonTriviallyEqualityComparableValueComparisonNonTriviallyCopyable
) = default;
3534 static_assert(!__is_trivially_equality_comparable(NonTriviallyEqualityComparableValueComparisonNonTriviallyCopyable
));
3536 struct TriviallyEqualityComparableRefComparisonNonTriviallyCopyable
{
3538 TriviallyEqualityComparableRefComparisonNonTriviallyCopyable(const TriviallyEqualityComparableRefComparisonNonTriviallyCopyable
&);
3540 friend bool operator==(const TriviallyEqualityComparableRefComparisonNonTriviallyCopyable
&, const TriviallyEqualityComparableRefComparisonNonTriviallyCopyable
&) = default;
3542 static_assert(__is_trivially_equality_comparable(TriviallyEqualityComparableRefComparisonNonTriviallyCopyable
));
3545 #endif // __cplusplus >= 202002L
3548 namespace can_pass_in_regs
{
3556 struct C
; // expected-note {{forward declaration}}
3562 static_assert(__can_pass_in_regs(A
), "");
3563 static_assert(__can_pass_in_regs(A
), "");
3564 static_assert(!__can_pass_in_regs(B
), "");
3565 static_assert(__can_pass_in_regs(D
), "");
3567 void test_errors() {
3568 (void)__can_pass_in_regs(const A
); // expected-error {{not an unqualified class type}}
3569 (void)__can_pass_in_regs(A
&); // expected-error {{not an unqualified class type}}
3570 (void)__can_pass_in_regs(A
&&); // expected-error {{not an unqualified class type}}
3571 (void)__can_pass_in_regs(const A
&); // expected-error {{not an unqualified class type}}
3572 (void)__can_pass_in_regs(C
); // expected-error {{incomplete type}}
3573 (void)__can_pass_in_regs(int); // expected-error {{not an unqualified class type}}
3574 (void)__can_pass_in_regs(int&); // expected-error {{not an unqualified class type}}
3579 template <class T
> using remove_const_t
= __remove_const(T
);
3581 void check_remove_const() {
3582 static_assert(__is_same(remove_const_t
<void>, void), "");
3583 static_assert(__is_same(remove_const_t
<const void>, void), "");
3584 static_assert(__is_same(remove_const_t
<int>, int), "");
3585 static_assert(__is_same(remove_const_t
<const int>, int), "");
3586 static_assert(__is_same(remove_const_t
<volatile int>, volatile int), "");
3587 static_assert(__is_same(remove_const_t
<const volatile int>, volatile int), "");
3588 static_assert(__is_same(remove_const_t
<int *>, int *), "");
3589 static_assert(__is_same(remove_const_t
<int *const>, int *), "");
3590 static_assert(__is_same(remove_const_t
<int const *const>, int const *), "");
3591 static_assert(__is_same(remove_const_t
<int const *const __restrict
>, int const *__restrict
), "");
3592 static_assert(__is_same(remove_const_t
<int &>, int &), "");
3593 static_assert(__is_same(remove_const_t
<int const &>, int const &), "");
3594 static_assert(__is_same(remove_const_t
<int &&>, int &&), "");
3595 static_assert(__is_same(remove_const_t
<int const &&>, int const &&), "");
3596 static_assert(__is_same(remove_const_t
<int()>, int()), "");
3597 static_assert(__is_same(remove_const_t
<int (*const)()>, int (*)()), "");
3598 static_assert(__is_same(remove_const_t
<int (&)()>, int (&)()), "");
3600 static_assert(__is_same(remove_const_t
<S
>, S
), "");
3601 static_assert(__is_same(remove_const_t
<const S
>, S
), "");
3602 static_assert(__is_same(remove_const_t
<volatile S
>, volatile S
), "");
3603 static_assert(__is_same(remove_const_t
<S
*__restrict
>, S
*__restrict
), "");
3604 static_assert(__is_same(remove_const_t
<const volatile S
>, volatile S
), "");
3605 static_assert(__is_same(remove_const_t
<S
*const volatile __restrict
>, S
*volatile __restrict
), "");
3606 static_assert(__is_same(remove_const_t
<int S::*const>, int S::*), "");
3607 static_assert(__is_same(remove_const_t
<int (S::*const)()>, int(S::*)()), "");
3610 template <class T
> using remove_restrict_t
= __remove_restrict(T
);
3612 void check_remove_restrict() {
3613 static_assert(__is_same(remove_restrict_t
<void>, void), "");
3614 static_assert(__is_same(remove_restrict_t
<int>, int), "");
3615 static_assert(__is_same(remove_restrict_t
<const int>, const int), "");
3616 static_assert(__is_same(remove_restrict_t
<volatile int>, volatile int), "");
3617 static_assert(__is_same(remove_restrict_t
<int *__restrict
>, int *), "");
3618 static_assert(__is_same(remove_restrict_t
<int *const volatile __restrict
>, int *const volatile), "");
3619 static_assert(__is_same(remove_restrict_t
<int *>, int *), "");
3620 static_assert(__is_same(remove_restrict_t
<int *__restrict
>, int *), "");
3621 static_assert(__is_same(remove_restrict_t
<int &>, int &), "");
3622 static_assert(__is_same(remove_restrict_t
<int &__restrict
>, int &), "");
3623 static_assert(__is_same(remove_restrict_t
<int &&>, int &&), "");
3624 static_assert(__is_same(remove_restrict_t
<int &&__restrict
>, int &&), "");
3625 static_assert(__is_same(remove_restrict_t
<int()>, int()), "");
3626 static_assert(__is_same(remove_restrict_t
<int (*const volatile)()>, int (*const volatile)()), "");
3627 static_assert(__is_same(remove_restrict_t
<int (&)()>, int (&)()), "");
3629 static_assert(__is_same(remove_restrict_t
<S
>, S
), "");
3630 static_assert(__is_same(remove_restrict_t
<const S
>, const S
), "");
3631 static_assert(__is_same(remove_restrict_t
<volatile S
>, volatile S
), "");
3632 static_assert(__is_same(remove_restrict_t
<S
*__restrict
>, S
*), "");
3633 static_assert(__is_same(remove_restrict_t
<S
*const volatile __restrict
>, S
*const volatile), "");
3634 static_assert(__is_same(remove_restrict_t
<int S::*__restrict
>, int S::*), "");
3635 static_assert(__is_same(remove_restrict_t
<int (S::*const volatile)()>, int(S::*const volatile)()), "");
3638 template <class T
> using remove_volatile_t
= __remove_volatile(T
);
3640 void check_remove_volatile() {
3641 static_assert(__is_same(remove_volatile_t
<void>, void), "");
3642 static_assert(__is_same(remove_volatile_t
<volatile void>, void), "");
3643 static_assert(__is_same(remove_volatile_t
<int>, int), "");
3644 static_assert(__is_same(remove_volatile_t
<const int>, const int), "");
3645 static_assert(__is_same(remove_volatile_t
<volatile int>, int), "");
3646 static_assert(__is_same(remove_volatile_t
<int *__restrict
>, int *__restrict
), "");
3647 static_assert(__is_same(remove_volatile_t
<const volatile int>, const int), "");
3648 static_assert(__is_same(remove_volatile_t
<int *const volatile __restrict
>, int *const __restrict
), "");
3649 static_assert(__is_same(remove_volatile_t
<int *>, int *), "");
3650 static_assert(__is_same(remove_volatile_t
<int *volatile>, int *), "");
3651 static_assert(__is_same(remove_volatile_t
<int volatile *volatile>, int volatile *), "");
3652 static_assert(__is_same(remove_volatile_t
<int &>, int &), "");
3653 static_assert(__is_same(remove_volatile_t
<int volatile &>, int volatile &), "");
3654 static_assert(__is_same(remove_volatile_t
<int &&>, int &&), "");
3655 static_assert(__is_same(remove_volatile_t
<int volatile &&>, int volatile &&), "");
3656 static_assert(__is_same(remove_volatile_t
<int()>, int()), "");
3657 static_assert(__is_same(remove_volatile_t
<int (*volatile)()>, int (*)()), "");
3658 static_assert(__is_same(remove_volatile_t
<int (&)()>, int (&)()), "");
3660 static_assert(__is_same(remove_volatile_t
<S
>, S
), "");
3661 static_assert(__is_same(remove_volatile_t
<const S
>, const S
), "");
3662 static_assert(__is_same(remove_volatile_t
<volatile S
>, S
), "");
3663 static_assert(__is_same(remove_volatile_t
<const volatile S
>, const S
), "");
3664 static_assert(__is_same(remove_volatile_t
<int S::*volatile>, int S::*), "");
3665 static_assert(__is_same(remove_volatile_t
<int (S::*volatile)()>, int(S::*)()), "");
3668 template <class T
> using remove_cv_t
= __remove_cv(T
);
3670 void check_remove_cv() {
3671 static_assert(__is_same(remove_cv_t
<void>, void), "");
3672 static_assert(__is_same(remove_cv_t
<const volatile void>, void), "");
3673 static_assert(__is_same(remove_cv_t
<int>, int), "");
3674 static_assert(__is_same(remove_cv_t
<const int>, int), "");
3675 static_assert(__is_same(remove_cv_t
<volatile int>, int), "");
3676 static_assert(__is_same(remove_cv_t
<const volatile int>, int), "");
3677 static_assert(__is_same(remove_cv_t
<int *>, int *), "");
3678 static_assert(__is_same(remove_cv_t
<int *const volatile>, int *), "");
3679 static_assert(__is_same(remove_cv_t
<int const *const volatile>, int const *), "");
3680 static_assert(__is_same(remove_cv_t
<int const *const volatile __restrict
>, int const *__restrict
), "");
3681 static_assert(__is_same(remove_cv_t
<int const *const volatile _Nonnull
>, int const *_Nonnull
), "");
3682 static_assert(__is_same(remove_cv_t
<int &>, int &), "");
3683 static_assert(__is_same(remove_cv_t
<int const volatile &>, int const volatile &), "");
3684 static_assert(__is_same(remove_cv_t
<int &&>, int &&), "");
3685 static_assert(__is_same(remove_cv_t
<int const volatile &&>, int const volatile &&), "");
3686 static_assert(__is_same(remove_cv_t
<int()>, int()), "");
3687 static_assert(__is_same(remove_cv_t
<int (*const volatile)()>, int (*)()), "");
3688 static_assert(__is_same(remove_cv_t
<int (&)()>, int (&)()), "");
3690 static_assert(__is_same(remove_cv_t
<S
>, S
), "");
3691 static_assert(__is_same(remove_cv_t
<const S
>, S
), "");
3692 static_assert(__is_same(remove_cv_t
<volatile S
>, S
), "");
3693 static_assert(__is_same(remove_cv_t
<const volatile S
>, S
), "");
3694 static_assert(__is_same(remove_cv_t
<int S::*const volatile>, int S::*), "");
3695 static_assert(__is_same(remove_cv_t
<int (S::*const volatile)()>, int(S::*)()), "");
3698 template <class T
> using add_pointer_t
= __add_pointer(T
);
3700 void add_pointer() {
3701 static_assert(__is_same(add_pointer_t
<void>, void *), "");
3702 static_assert(__is_same(add_pointer_t
<const void>, const void *), "");
3703 static_assert(__is_same(add_pointer_t
<volatile void>, volatile void *), "");
3704 static_assert(__is_same(add_pointer_t
<const volatile void>, const volatile void *), "");
3705 static_assert(__is_same(add_pointer_t
<int>, int *), "");
3706 static_assert(__is_same(add_pointer_t
<const int>, const int *), "");
3707 static_assert(__is_same(add_pointer_t
<volatile int>, volatile int *), "");
3708 static_assert(__is_same(add_pointer_t
<const volatile int>, const volatile int *), "");
3709 static_assert(__is_same(add_pointer_t
<int *>, int **), "");
3710 static_assert(__is_same(add_pointer_t
<int &>, int *), "");
3711 static_assert(__is_same(add_pointer_t
<int &&>, int *), "");
3712 static_assert(__is_same(add_pointer_t
<int()>, int (*)()), "");
3713 static_assert(__is_same(add_pointer_t
<int (*)()>, int (**)()), "");
3714 static_assert(__is_same(add_pointer_t
<int (&)()>, int (*)()), "");
3716 static_assert(__is_same(add_pointer_t
<S
>, S
*), "");
3717 static_assert(__is_same(add_pointer_t
<const S
>, const S
*), "");
3718 static_assert(__is_same(add_pointer_t
<volatile S
>, volatile S
*), "");
3719 static_assert(__is_same(add_pointer_t
<const volatile S
>, const volatile S
*), "");
3720 static_assert(__is_same(add_pointer_t
<int S::*>, int S::**), "");
3721 static_assert(__is_same(add_pointer_t
<int (S::*)()>, int(S::**)()), "");
3723 static_assert(__is_same(add_pointer_t
<int __attribute__((address_space(1)))>, int __attribute__((address_space(1))) *), "");
3724 static_assert(__is_same(add_pointer_t
<S
__attribute__((address_space(2)))>, S
__attribute__((address_space(2))) *), "");
3727 template <class T
> using remove_pointer_t
= __remove_pointer(T
);
3729 void remove_pointer() {
3730 static_assert(__is_same(remove_pointer_t
<void>, void), "");
3731 static_assert(__is_same(remove_pointer_t
<const void>, const void), "");
3732 static_assert(__is_same(remove_pointer_t
<volatile void>, volatile void), "");
3733 static_assert(__is_same(remove_pointer_t
<const volatile void>, const volatile void), "");
3734 static_assert(__is_same(remove_pointer_t
<int>, int), "");
3735 static_assert(__is_same(remove_pointer_t
<const int>, const int), "");
3736 static_assert(__is_same(remove_pointer_t
<volatile int>, volatile int), "");
3737 static_assert(__is_same(remove_pointer_t
<const volatile int>, const volatile int), "");
3738 static_assert(__is_same(remove_pointer_t
<int *>, int), "");
3739 static_assert(__is_same(remove_pointer_t
<const int *>, const int), "");
3740 static_assert(__is_same(remove_pointer_t
<volatile int *>, volatile int), "");
3741 static_assert(__is_same(remove_pointer_t
<const volatile int *>, const volatile int), "");
3742 static_assert(__is_same(remove_pointer_t
<int *const>, int), "");
3743 static_assert(__is_same(remove_pointer_t
<int *volatile>, int), "");
3744 static_assert(__is_same(remove_pointer_t
<int *const volatile>, int), "");
3745 static_assert(__is_same(remove_pointer_t
<int &>, int &), "");
3746 static_assert(__is_same(remove_pointer_t
<int &&>, int &&), "");
3747 static_assert(__is_same(remove_pointer_t
<int()>, int()), "");
3748 static_assert(__is_same(remove_pointer_t
<int (*)()>, int()), "");
3749 static_assert(__is_same(remove_pointer_t
<int (&)()>, int (&)()), "");
3751 static_assert(__is_same(remove_pointer_t
<S
>, S
), "");
3752 static_assert(__is_same(remove_pointer_t
<const S
>, const S
), "");
3753 static_assert(__is_same(remove_pointer_t
<volatile S
>, volatile S
), "");
3754 static_assert(__is_same(remove_pointer_t
<const volatile S
>, const volatile S
), "");
3755 static_assert(__is_same(remove_pointer_t
<int S::*>, int S::*), "");
3756 static_assert(__is_same(remove_pointer_t
<int (S::*)()>, int(S::*)()), "");
3758 static_assert(__is_same(remove_pointer_t
<int __attribute__((address_space(1))) *>, int __attribute__((address_space(1)))), "");
3759 static_assert(__is_same(remove_pointer_t
<S
__attribute__((address_space(2))) *>, S
__attribute__((address_space(2)))), "");
3761 static_assert(__is_same(remove_pointer_t
<int (^)(char)>, int (^)(char)), "");
3764 template <class T
> using add_lvalue_reference_t
= __add_lvalue_reference(T
);
3766 void add_lvalue_reference() {
3767 static_assert(__is_same(add_lvalue_reference_t
<void>, void), "");
3768 static_assert(__is_same(add_lvalue_reference_t
<const void>, const void), "");
3769 static_assert(__is_same(add_lvalue_reference_t
<volatile void>, volatile void), "");
3770 static_assert(__is_same(add_lvalue_reference_t
<const volatile void>, const volatile void), "");
3771 static_assert(__is_same(add_lvalue_reference_t
<int>, int &), "");
3772 static_assert(__is_same(add_lvalue_reference_t
<const int>, const int &), "");
3773 static_assert(__is_same(add_lvalue_reference_t
<volatile int>, volatile int &), "");
3774 static_assert(__is_same(add_lvalue_reference_t
<const volatile int>, const volatile int &), "");
3775 static_assert(__is_same(add_lvalue_reference_t
<int *>, int *&), "");
3776 static_assert(__is_same(add_lvalue_reference_t
<int &>, int &), "");
3777 static_assert(__is_same(add_lvalue_reference_t
<int &&>, int &), ""); // reference collapsing
3778 static_assert(__is_same(add_lvalue_reference_t
<int()>, int (&)()), "");
3779 static_assert(__is_same(add_lvalue_reference_t
<int (*)()>, int (*&)()), "");
3780 static_assert(__is_same(add_lvalue_reference_t
<int (&)()>, int (&)()), "");
3782 static_assert(__is_same(add_lvalue_reference_t
<S
>, S
&), "");
3783 static_assert(__is_same(add_lvalue_reference_t
<const S
>, const S
&), "");
3784 static_assert(__is_same(add_lvalue_reference_t
<volatile S
>, volatile S
&), "");
3785 static_assert(__is_same(add_lvalue_reference_t
<const volatile S
>, const volatile S
&), "");
3786 static_assert(__is_same(add_lvalue_reference_t
<int S::*>, int S::*&), "");
3787 static_assert(__is_same(add_lvalue_reference_t
<int (S::*)()>, int(S::*&)()), "");
3790 template <class T
> using add_rvalue_reference_t
= __add_rvalue_reference(T
);
3792 void add_rvalue_reference() {
3793 static_assert(__is_same(add_rvalue_reference_t
<void>, void), "");
3794 static_assert(__is_same(add_rvalue_reference_t
<const void>, const void), "");
3795 static_assert(__is_same(add_rvalue_reference_t
<volatile void>, volatile void), "");
3796 static_assert(__is_same(add_rvalue_reference_t
<const volatile void>, const volatile void), "");
3797 static_assert(__is_same(add_rvalue_reference_t
<int>, int &&), "");
3798 static_assert(__is_same(add_rvalue_reference_t
<const int>, const int &&), "");
3799 static_assert(__is_same(add_rvalue_reference_t
<volatile int>, volatile int &&), "");
3800 static_assert(__is_same(add_rvalue_reference_t
<const volatile int>, const volatile int &&), "");
3801 static_assert(__is_same(add_rvalue_reference_t
<int *>, int *&&), "");
3802 static_assert(__is_same(add_rvalue_reference_t
<int &>, int &), ""); // reference collapsing
3803 static_assert(__is_same(add_rvalue_reference_t
<int &&>, int &&), "");
3804 static_assert(__is_same(add_rvalue_reference_t
<int()>, int(&&)()), "");
3805 static_assert(__is_same(add_rvalue_reference_t
<int (*)()>, int (*&&)()), "");
3806 static_assert(__is_same(add_rvalue_reference_t
<int (&)()>, int (&)()), ""); // reference collapsing
3808 static_assert(__is_same(add_rvalue_reference_t
<S
>, S
&&), "");
3809 static_assert(__is_same(add_rvalue_reference_t
<const S
>, const S
&&), "");
3810 static_assert(__is_same(add_rvalue_reference_t
<volatile S
>, volatile S
&&), "");
3811 static_assert(__is_same(add_rvalue_reference_t
<const volatile S
>, const volatile S
&&), "");
3812 static_assert(__is_same(add_rvalue_reference_t
<int S::*>, int S::*&&), "");
3813 static_assert(__is_same(add_rvalue_reference_t
<int (S::*)()>, int(S::* &&)()), "");
3816 template <class T
> using remove_reference_t
= __remove_reference_t(T
);
3818 void check_remove_reference() {
3819 static_assert(__is_same(remove_reference_t
<void>, void), "");
3820 static_assert(__is_same(remove_reference_t
<const volatile void>, const volatile void), "");
3821 static_assert(__is_same(remove_reference_t
<int>, int), "");
3822 static_assert(__is_same(remove_reference_t
<const int>, const int), "");
3823 static_assert(__is_same(remove_reference_t
<volatile int>, volatile int), "");
3824 static_assert(__is_same(remove_reference_t
<const volatile int>, const volatile int), "");
3825 static_assert(__is_same(remove_reference_t
<int *>, int *), "");
3826 static_assert(__is_same(remove_reference_t
<int *const volatile>, int *const volatile), "");
3827 static_assert(__is_same(remove_reference_t
<int const *const volatile>, int const *const volatile), "");
3828 static_assert(__is_same(remove_reference_t
<int &>, int), "");
3829 static_assert(__is_same(remove_reference_t
<int const volatile &>, int const volatile), "");
3830 static_assert(__is_same(remove_reference_t
<int &&>, int), "");
3831 static_assert(__is_same(remove_reference_t
<int const volatile &&>, int const volatile), "");
3832 static_assert(__is_same(remove_reference_t
<int()>, int()), "");
3833 static_assert(__is_same(remove_reference_t
<int (*const volatile)()>, int (*const volatile)()), "");
3834 static_assert(__is_same(remove_reference_t
<int (&)()>, int()), "");
3836 static_assert(__is_same(remove_reference_t
<S
>, S
), "");
3837 static_assert(__is_same(remove_reference_t
<S
&>, S
), "");
3838 static_assert(__is_same(remove_reference_t
<S
&&>, S
), "");
3839 static_assert(__is_same(remove_reference_t
<const S
>, const S
), "");
3840 static_assert(__is_same(remove_reference_t
<const S
&>, const S
), "");
3841 static_assert(__is_same(remove_reference_t
<const S
&&>, const S
), "");
3842 static_assert(__is_same(remove_reference_t
<volatile S
>, volatile S
), "");
3843 static_assert(__is_same(remove_reference_t
<volatile S
&>, volatile S
), "");
3844 static_assert(__is_same(remove_reference_t
<volatile S
&&>, volatile S
), "");
3845 static_assert(__is_same(remove_reference_t
<const volatile S
>, const volatile S
), "");
3846 static_assert(__is_same(remove_reference_t
<const volatile S
&>, const volatile S
), "");
3847 static_assert(__is_same(remove_reference_t
<const volatile S
&&>, const volatile S
), "");
3848 static_assert(__is_same(remove_reference_t
<int S::*const volatile &>, int S::*const volatile), "");
3849 static_assert(__is_same(remove_reference_t
<int (S::*const volatile &)()>, int(S::*const volatile)()), "");
3850 static_assert(__is_same(remove_reference_t
<int (S::*const volatile &&)() &>, int(S::*const volatile)() &), "");
3853 template <class T
> using remove_cvref_t
= __remove_cvref(T
);
3855 void check_remove_cvref() {
3856 static_assert(__is_same(remove_cvref_t
<void>, void), "");
3857 static_assert(__is_same(remove_cvref_t
<const volatile void>, void), "");
3858 static_assert(__is_same(remove_cvref_t
<int>, int), "");
3859 static_assert(__is_same(remove_cvref_t
<const int>, int), "");
3860 static_assert(__is_same(remove_cvref_t
<volatile int>, int), "");
3861 static_assert(__is_same(remove_cvref_t
<const volatile int>, int), "");
3862 static_assert(__is_same(remove_cvref_t
<int *>, int *), "");
3863 static_assert(__is_same(remove_cvref_t
<int *const volatile>, int *), "");
3864 static_assert(__is_same(remove_cvref_t
<int const *const volatile>, int const *), "");
3865 static_assert(__is_same(remove_cvref_t
<int const *const volatile __restrict
>, int const *__restrict
), "");
3866 static_assert(__is_same(remove_cvref_t
<int const *const volatile _Nonnull
>, int const *_Nonnull
), "");
3867 static_assert(__is_same(remove_cvref_t
<int &>, int), "");
3868 static_assert(__is_same(remove_cvref_t
<int const volatile &>, int), "");
3869 static_assert(__is_same(remove_cvref_t
<int &&>, int), "");
3870 static_assert(__is_same(remove_cvref_t
<int const volatile &&>, int), "");
3871 static_assert(__is_same(remove_cvref_t
<int()>, int()), "");
3872 static_assert(__is_same(remove_cvref_t
<int (*const volatile)()>, int (*)()), "");
3873 static_assert(__is_same(remove_cvref_t
<int (&)()>, int()), "");
3875 static_assert(__is_same(remove_cvref_t
<S
>, S
), "");
3876 static_assert(__is_same(remove_cvref_t
<S
&>, S
), "");
3877 static_assert(__is_same(remove_cvref_t
<S
&&>, S
), "");
3878 static_assert(__is_same(remove_cvref_t
<const S
>, S
), "");
3879 static_assert(__is_same(remove_cvref_t
<const S
&>, S
), "");
3880 static_assert(__is_same(remove_cvref_t
<const S
&&>, S
), "");
3881 static_assert(__is_same(remove_cvref_t
<volatile S
>, S
), "");
3882 static_assert(__is_same(remove_cvref_t
<volatile S
&>, S
), "");
3883 static_assert(__is_same(remove_cvref_t
<volatile S
&&>, S
), "");
3884 static_assert(__is_same(remove_cvref_t
<const volatile S
>, S
), "");
3885 static_assert(__is_same(remove_cvref_t
<const volatile S
&>, S
), "");
3886 static_assert(__is_same(remove_cvref_t
<const volatile S
&&>, S
), "");
3887 static_assert(__is_same(remove_cvref_t
<int S::*const volatile>, int S::*), "");
3888 static_assert(__is_same(remove_cvref_t
<int (S::*const volatile)()>, int(S::*)()), "");
3889 static_assert(__is_same(remove_cvref_t
<int (S::*const volatile)() &>, int(S::*)() &), "");
3890 static_assert(__is_same(remove_cvref_t
<int (S::*const volatile)() &&>, int(S::*)() &&), "");
3893 template <class T
> using decay_t
= __decay(T
);
3895 void check_decay() {
3896 static_assert(__is_same(decay_t
<void>, void), "");
3897 static_assert(__is_same(decay_t
<const volatile void>, void), "");
3898 static_assert(__is_same(decay_t
<int>, int), "");
3899 static_assert(__is_same(decay_t
<const int>, int), "");
3900 static_assert(__is_same(decay_t
<volatile int>, int), "");
3901 static_assert(__is_same(decay_t
<const volatile int>, int), "");
3902 static_assert(__is_same(decay_t
<int *>, int *), "");
3903 static_assert(__is_same(decay_t
<int *const volatile>, int *), "");
3904 static_assert(__is_same(decay_t
<int *const volatile __restrict
>, int *), "");
3905 static_assert(__is_same(decay_t
<int const *const volatile>, int const *), "");
3906 static_assert(__is_same(decay_t
<int const *const volatile _Nonnull
>, int const *), "");
3907 static_assert(__is_same(decay_t
<int &>, int), "");
3908 static_assert(__is_same(decay_t
<int const volatile &>, int), "");
3909 static_assert(__is_same(decay_t
<int &&>, int), "");
3910 static_assert(__is_same(decay_t
<int const volatile &&>, int), "");
3911 static_assert(__is_same(decay_t
<int()>, int (*)()), "");
3912 static_assert(__is_same(decay_t
<int (*)()>, int (*)()), "");
3913 static_assert(__is_same(decay_t
<int (*const)()>, int (*)()), "");
3914 static_assert(__is_same(decay_t
<int (*volatile)()>, int (*)()), "");
3915 static_assert(__is_same(decay_t
<int (*const volatile)()>, int (*)()), "");
3916 static_assert(__is_same(decay_t
<int (&)()>, int (*)()), "");
3917 static_assert(__is_same(decay_t
<IntAr
>, int *), "");
3918 static_assert(__is_same(decay_t
<IntArNB
>, int *), "");
3920 static_assert(__is_same(decay_t
<S
>, S
), "");
3921 static_assert(__is_same(decay_t
<S
&>, S
), "");
3922 static_assert(__is_same(decay_t
<S
&&>, S
), "");
3923 static_assert(__is_same(decay_t
<const S
>, S
), "");
3924 static_assert(__is_same(decay_t
<const S
&>, S
), "");
3925 static_assert(__is_same(decay_t
<const S
&&>, S
), "");
3926 static_assert(__is_same(decay_t
<volatile S
>, S
), "");
3927 static_assert(__is_same(decay_t
<volatile S
&>, S
), "");
3928 static_assert(__is_same(decay_t
<volatile S
&&>, S
), "");
3929 static_assert(__is_same(decay_t
<const volatile S
>, S
), "");
3930 static_assert(__is_same(decay_t
<const volatile S
&>, S
), "");
3931 static_assert(__is_same(decay_t
<const volatile S
&&>, S
), "");
3932 static_assert(__is_same(decay_t
<int S::*const volatile>, int S::*), "");
3933 static_assert(__is_same(decay_t
<int (S::*const volatile)()>, int(S::*)()), "");
3934 static_assert(__is_same(decay_t
<int S::*const volatile &>, int S::*), "");
3935 static_assert(__is_same(decay_t
<int (S::*const volatile &)()>, int(S::*)()), "");
3936 static_assert(__is_same(decay_t
<int S::*const volatile &&>, int S::*), "");
3939 template <class T
> struct CheckAbominableFunction
{};
3941 struct CheckAbominableFunction
<M
S::*> {
3942 static void checks() {
3943 static_assert(__is_same(add_lvalue_reference_t
<M
>, M
), "");
3944 static_assert(__is_same(add_pointer_t
<M
>, M
), "");
3945 static_assert(__is_same(add_rvalue_reference_t
<M
>, M
), "");
3946 static_assert(__is_same(decay_t
<M
>, M
), "");
3947 static_assert(__is_same(remove_const_t
<M
>, M
), "");
3948 static_assert(__is_same(remove_volatile_t
<M
>, M
), "");
3949 static_assert(__is_same(remove_cv_t
<M
>, M
), "");
3950 static_assert(__is_same(remove_cvref_t
<M
>, M
), "");
3951 static_assert(__is_same(remove_pointer_t
<M
>, M
), "");
3952 static_assert(__is_same(remove_reference_t
<M
>, M
), "");
3954 static_assert(!__is_referenceable(M
), "");
3958 void check_abominable_function() {
3959 { CheckAbominableFunction
<int (S::*)() &> x
; }
3960 { CheckAbominableFunction
<int (S::*)() &&> x
; }
3961 { CheckAbominableFunction
<int (S::*)() const> x
; }
3962 { CheckAbominableFunction
<int (S::*)() const &> x
; }
3963 { CheckAbominableFunction
<int (S::*)() const &&> x
; }
3964 { CheckAbominableFunction
<int (S::*)() volatile> x
; }
3965 { CheckAbominableFunction
<int (S::*)() volatile &> x
; }
3966 { CheckAbominableFunction
<int (S::*)() volatile &&> x
; }
3967 { CheckAbominableFunction
<int (S::*)() const volatile> x
; }
3968 { CheckAbominableFunction
<int (S::*)() const volatile &> x
; }
3969 { CheckAbominableFunction
<int (S::*)() const volatile &&> x
; }
3972 template <class T
> using make_signed_t
= __make_signed(T
);
3973 template <class T
, class Expected
>
3974 void check_make_signed() {
3975 static_assert(__is_same(make_signed_t
<T
>, Expected
), "");
3976 static_assert(__is_same(make_signed_t
<const T
>, const Expected
), "");
3977 static_assert(__is_same(make_signed_t
<volatile T
>, volatile Expected
), "");
3978 static_assert(__is_same(make_signed_t
<const volatile T
>, const volatile Expected
), "");
3981 #if defined(__ILP32__) || defined(__LLP64__)
3982 using Int64
= long long;
3983 using UInt64
= unsigned long long;
3984 #elif defined(__LP64__) || defined(__ILP64__) || defined(__SILP64__)
3986 using UInt64
= unsigned long;
3988 #error Programming model currently unsupported; please add a new entry.
3991 enum UnscopedBool
: bool {}; // deliberately char
3992 enum class ScopedBool
: bool {}; // deliberately char
3993 enum UnscopedChar
: char {}; // deliberately char
3994 enum class ScopedChar
: char {}; // deliberately char
3995 enum UnscopedUChar
: unsigned char {};
3996 enum class ScopedUChar
: unsigned char {};
3997 enum UnscopedLongLong
: long long {};
3998 enum UnscopedULongLong
: unsigned long long {};
3999 enum class ScopedLongLong
: long long {};
4000 enum class ScopedULongLong
: unsigned long long {};
4001 enum class UnscopedInt128
: __int128
{};
4002 enum class ScopedInt128
: __int128
{};
4003 enum class UnscopedUInt128
: unsigned __int128
{};
4004 enum class ScopedUInt128
: unsigned __int128
{};
4006 void make_signed() {
4007 check_make_signed
<char, signed char>();
4008 check_make_signed
<signed char, signed char>();
4009 check_make_signed
<unsigned char, signed char>();
4010 check_make_signed
<short, short>();
4011 check_make_signed
<unsigned short, short>();
4012 check_make_signed
<int, int>();
4013 check_make_signed
<unsigned int, int>();
4014 check_make_signed
<long, long>();
4015 check_make_signed
<unsigned long, long>();
4016 check_make_signed
<long long, long long>();
4017 check_make_signed
<unsigned long long, long long>();
4018 check_make_signed
<__int128
, __int128
>();
4019 check_make_signed
<__uint128_t
, __int128
>();
4020 check_make_signed
<_BitInt(65), _BitInt(65)>();
4021 check_make_signed
<unsigned _BitInt(65), _BitInt(65)>();
4023 check_make_signed
<wchar_t, int>();
4024 #if __cplusplus >= 202002L
4025 check_make_signed
<char8_t
, signed char>();
4027 #if __cplusplus >= 201103L
4028 check_make_signed
<char16_t
, short>();
4029 check_make_signed
<char32_t
, int>();
4032 check_make_signed
<UnscopedChar
, signed char>();
4033 check_make_signed
<ScopedChar
, signed char>();
4034 check_make_signed
<UnscopedUChar
, signed char>();
4035 check_make_signed
<ScopedUChar
, signed char>();
4037 check_make_signed
<UnscopedLongLong
, Int64
>();
4038 check_make_signed
<UnscopedULongLong
, Int64
>();
4039 check_make_signed
<ScopedLongLong
, Int64
>();
4040 check_make_signed
<ScopedULongLong
, Int64
>();
4042 check_make_signed
<UnscopedInt128
, __int128
>();
4043 check_make_signed
<ScopedInt128
, __int128
>();
4044 check_make_signed
<UnscopedUInt128
, __int128
>();
4045 check_make_signed
<ScopedUInt128
, __int128
>();
4047 { using ExpectedError
= __make_signed(bool); }
4048 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'bool'}}
4049 { using ExpectedError
= __make_signed(UnscopedBool
); }
4050 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'UnscopedBool' whose underlying type is 'bool'}}
4051 { using ExpectedError
= __make_signed(ScopedBool
); }
4052 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'ScopedBool' whose underlying type is 'bool'}}
4053 { using ExpectedError
= __make_signed(unsigned _BitInt(1)); }
4054 // expected-error@*:*{{'make_signed' is only compatible with non-_BitInt(1) integers and enum types, but was given 'unsigned _BitInt(1)'}}
4055 { using ExpectedError
= __make_signed(int[]); }
4056 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int[]'}}
4057 { using ExpectedError
= __make_signed(int[5]); }
4058 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int[5]'}}
4059 { using ExpectedError
= __make_signed(void); }
4060 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'void'}}
4061 { using ExpectedError
= __make_signed(int *); }
4062 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int *'}}
4063 { using ExpectedError
= __make_signed(int &); }
4064 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int &'}}
4065 { using ExpectedError
= __make_signed(int &&); }
4066 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int &&'}}
4067 { using ExpectedError
= __make_signed(float); }
4068 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'float'}}
4069 { using ExpectedError
= __make_signed(double); }
4070 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'double'}}
4071 { using ExpectedError
= __make_signed(long double); }
4072 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'long double'}}
4073 { using ExpectedError
= __make_signed(S
); }
4074 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'S'}}
4075 { using ExpectedError
= __make_signed(S
*); }
4076 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'S *'}}
4077 { using ExpectedError
= __make_signed(int S::*); }
4078 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int S::*'}}
4079 { using ExpectedError
= __make_signed(int(S::*)()); }
4080 // expected-error@*:*{{'make_signed' is only compatible with non-bool integers and enum types, but was given 'int (S::*)()'}}
4084 using make_unsigned_t
= __make_unsigned(T
);
4086 template <class T
, class Expected
>
4087 void check_make_unsigned() {
4088 static_assert(__is_same(make_unsigned_t
<T
>, Expected
), "");
4089 static_assert(__is_same(make_unsigned_t
<const T
>, const Expected
), "");
4090 static_assert(__is_same(make_unsigned_t
<volatile T
>, volatile Expected
), "");
4091 static_assert(__is_same(make_unsigned_t
<const volatile T
>, const volatile Expected
), "");
4094 void make_unsigned() {
4095 check_make_unsigned
<char, unsigned char>();
4096 check_make_unsigned
<signed char, unsigned char>();
4097 check_make_unsigned
<unsigned char, unsigned char>();
4098 check_make_unsigned
<short, unsigned short>();
4099 check_make_unsigned
<unsigned short, unsigned short>();
4100 check_make_unsigned
<int, unsigned int>();
4101 check_make_unsigned
<unsigned int, unsigned int>();
4102 check_make_unsigned
<long, unsigned long>();
4103 check_make_unsigned
<unsigned long, unsigned long>();
4104 check_make_unsigned
<long long, unsigned long long>();
4105 check_make_unsigned
<unsigned long long, unsigned long long>();
4106 check_make_unsigned
<__int128
, __uint128_t
>();
4107 check_make_unsigned
<__uint128_t
, __uint128_t
>();
4108 check_make_unsigned
<_BitInt(65), unsigned _BitInt(65)>();
4109 check_make_unsigned
<unsigned _BitInt(65), unsigned _BitInt(65)>();
4111 check_make_unsigned
<wchar_t, unsigned int>();
4112 #if __cplusplus >= 202002L
4113 check_make_unsigned
<char8_t
, unsigned char>();
4115 #if __cplusplus >= 201103L
4116 check_make_unsigned
<char16_t
, unsigned short>();
4117 check_make_unsigned
<char32_t
, unsigned int>();
4120 check_make_unsigned
<UnscopedChar
, unsigned char>();
4121 check_make_unsigned
<ScopedChar
, unsigned char>();
4122 check_make_unsigned
<UnscopedUChar
, unsigned char>();
4123 check_make_unsigned
<ScopedUChar
, unsigned char>();
4125 check_make_unsigned
<UnscopedLongLong
, UInt64
>();
4126 check_make_unsigned
<UnscopedULongLong
, UInt64
>();
4127 check_make_unsigned
<ScopedLongLong
, UInt64
>();
4128 check_make_unsigned
<ScopedULongLong
, UInt64
>();
4130 check_make_unsigned
<UnscopedInt128
, unsigned __int128
>();
4131 check_make_unsigned
<ScopedInt128
, unsigned __int128
>();
4132 check_make_unsigned
<UnscopedUInt128
, unsigned __int128
>();
4133 check_make_unsigned
<ScopedUInt128
, unsigned __int128
>();
4135 { using ExpectedError
= __make_unsigned(bool); }
4136 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'bool'}}
4137 { using ExpectedError
= __make_unsigned(UnscopedBool
); }
4138 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'UnscopedBool' whose underlying type is 'bool'}}
4139 { using ExpectedError
= __make_unsigned(ScopedBool
); }
4140 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'ScopedBool' whose underlying type is 'bool'}}
4141 { using ExpectedError
= __make_unsigned(unsigned _BitInt(1)); }
4142 // expected-error@*:*{{'make_unsigned' is only compatible with non-_BitInt(1) integers and enum types, but was given 'unsigned _BitInt(1)'}}
4143 { using ExpectedError
= __make_unsigned(int[]); }
4144 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int[]'}}
4145 { using ExpectedError
= __make_unsigned(int[5]); }
4146 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int[5]'}}
4147 { using ExpectedError
= __make_unsigned(void); }
4148 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'void'}}
4149 { using ExpectedError
= __make_unsigned(int *); }
4150 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int *'}}
4151 { using ExpectedError
= __make_unsigned(int &); }
4152 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int &'}}
4153 { using ExpectedError
= __make_unsigned(int &&); }
4154 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int &&'}}
4155 { using ExpectedError
= __make_unsigned(float); }
4156 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'float'}}
4157 { using ExpectedError
= __make_unsigned(double); }
4158 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'double'}}
4159 { using ExpectedError
= __make_unsigned(long double); }
4160 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'long double'}}
4161 { using ExpectedError
= __make_unsigned(S
); }
4162 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'S'}}
4163 { using ExpectedError
= __make_unsigned(S
*); }
4164 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'S *'}}
4165 { using ExpectedError
= __make_unsigned(int S::*); }
4166 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int S::*'}}
4167 { using ExpectedError
= __make_unsigned(int(S::*)()); }
4168 // expected-error@*:*{{'make_unsigned' is only compatible with non-bool integers and enum types, but was given 'int (S::*)()'}}
4171 template <class T
> using remove_extent_t
= __remove_extent(T
);
4173 void remove_extent() {
4174 static_assert(__is_same(remove_extent_t
<void>, void), "");
4175 static_assert(__is_same(remove_extent_t
<int>, int), "");
4176 static_assert(__is_same(remove_extent_t
<int[]>, int), "");
4177 static_assert(__is_same(remove_extent_t
<int[1]>, int), "");
4178 static_assert(__is_same(remove_extent_t
<int[1][2]>, int[2]), "");
4179 static_assert(__is_same(remove_extent_t
<int[][2]>, int[2]), "");
4180 static_assert(__is_same(remove_extent_t
<const int[]>, const int), "");
4181 static_assert(__is_same(remove_extent_t
<const int[1]>, const int), "");
4182 static_assert(__is_same(remove_extent_t
<const int[1][2]>, const int[2]), "");
4183 static_assert(__is_same(remove_extent_t
<const int[][2]>, const int[2]), "");
4184 static_assert(__is_same(remove_extent_t
<volatile int[]>, volatile int), "");
4185 static_assert(__is_same(remove_extent_t
<volatile int[1]>, volatile int), "");
4186 static_assert(__is_same(remove_extent_t
<volatile int[1][2]>, volatile int[2]), "");
4187 static_assert(__is_same(remove_extent_t
<volatile int[][2]>, volatile int[2]), "");
4188 static_assert(__is_same(remove_extent_t
<const volatile int[]>, const volatile int), "");
4189 static_assert(__is_same(remove_extent_t
<const volatile int[1]>, const volatile int), "");
4190 static_assert(__is_same(remove_extent_t
<const volatile int[1][2]>, const volatile int[2]), "");
4191 static_assert(__is_same(remove_extent_t
<const volatile int[][2]>, const volatile int[2]), "");
4192 static_assert(__is_same(remove_extent_t
<int *>, int *), "");
4193 static_assert(__is_same(remove_extent_t
<int &>, int &), "");
4194 static_assert(__is_same(remove_extent_t
<int &&>, int &&), "");
4195 static_assert(__is_same(remove_extent_t
<int()>, int()), "");
4196 static_assert(__is_same(remove_extent_t
<int (*)()>, int (*)()), "");
4197 static_assert(__is_same(remove_extent_t
<int (&)()>, int (&)()), "");
4199 static_assert(__is_same(remove_extent_t
<S
>, S
), "");
4200 static_assert(__is_same(remove_extent_t
<int S::*>, int S::*), "");
4201 static_assert(__is_same(remove_extent_t
<int (S::*)()>, int(S::*)()), "");
4203 using SomeArray
= int[1][2];
4204 static_assert(__is_same(remove_extent_t
<const SomeArray
>, const int[2]), "");
4207 template <class T
> using remove_all_extents_t
= __remove_all_extents(T
);
4209 void remove_all_extents() {
4210 static_assert(__is_same(remove_all_extents_t
<void>, void), "");
4211 static_assert(__is_same(remove_all_extents_t
<int>, int), "");
4212 static_assert(__is_same(remove_all_extents_t
<const int>, const int), "");
4213 static_assert(__is_same(remove_all_extents_t
<volatile int>, volatile int), "");
4214 static_assert(__is_same(remove_all_extents_t
<const volatile int>, const volatile int), "");
4215 static_assert(__is_same(remove_all_extents_t
<int[]>, int), "");
4216 static_assert(__is_same(remove_all_extents_t
<int[1]>, int), "");
4217 static_assert(__is_same(remove_all_extents_t
<int[1][2]>, int), "");
4218 static_assert(__is_same(remove_all_extents_t
<int[][2]>, int), "");
4219 static_assert(__is_same(remove_all_extents_t
<const int[]>, const int), "");
4220 static_assert(__is_same(remove_all_extents_t
<const int[1]>, const int), "");
4221 static_assert(__is_same(remove_all_extents_t
<const int[1][2]>, const int), "");
4222 static_assert(__is_same(remove_all_extents_t
<const int[][2]>, const int), "");
4223 static_assert(__is_same(remove_all_extents_t
<volatile int[]>, volatile int), "");
4224 static_assert(__is_same(remove_all_extents_t
<volatile int[1]>, volatile int), "");
4225 static_assert(__is_same(remove_all_extents_t
<volatile int[1][2]>, volatile int), "");
4226 static_assert(__is_same(remove_all_extents_t
<volatile int[][2]>, volatile int), "");
4227 static_assert(__is_same(remove_all_extents_t
<const volatile int[]>, const volatile int), "");
4228 static_assert(__is_same(remove_all_extents_t
<const volatile int[1]>, const volatile int), "");
4229 static_assert(__is_same(remove_all_extents_t
<const volatile int[1][2]>, const volatile int), "");
4230 static_assert(__is_same(remove_all_extents_t
<const volatile int[][2]>, const volatile int), "");
4231 static_assert(__is_same(remove_all_extents_t
<int *>, int *), "");
4232 static_assert(__is_same(remove_all_extents_t
<int &>, int &), "");
4233 static_assert(__is_same(remove_all_extents_t
<int &&>, int &&), "");
4234 static_assert(__is_same(remove_all_extents_t
<int()>, int()), "");
4235 static_assert(__is_same(remove_all_extents_t
<int (*)()>, int (*)()), "");
4236 static_assert(__is_same(remove_all_extents_t
<int (&)()>, int (&)()), "");
4238 static_assert(__is_same(remove_all_extents_t
<S
>, S
), "");
4239 static_assert(__is_same(remove_all_extents_t
<int S::*>, int S::*), "");
4240 static_assert(__is_same(remove_all_extents_t
<int (S::*)()>, int(S::*)()), "");
4242 using SomeArray
= int[1][2];
4243 static_assert(__is_same(remove_all_extents_t
<const SomeArray
>, const int), "");