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