1 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fms-extensions -fdump-record-layouts -fsyntax-only -Wno-inaccessible-base %s 2>&1 \ 2 // RUN: | FileCheck %s 3 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fms-extensions -fdump-record-layouts -fsyntax-only -Wno-inaccessible-base %s 2>/dev/null \ 4 // RUN: | FileCheck %s -check-prefix CHECK-X64 5 6 extern "C" int printf(const char *fmt, ...); 7 char buffer[419430400]; 8 9 struct A { 10 char a; AA11 A() { 12 printf("A = %d\n", (int)((char*)this - buffer)); 13 printf("A.a = %d\n", (int)((char*)&a - buffer)); 14 } 15 }; 16 17 struct B { 18 __declspec(align(4)) long long a; BB19 B() { 20 printf("B = %d\n", (int)((char*)this - buffer)); 21 printf("B.a = %d\n", (int)((char*)&a - buffer)); 22 } 23 }; 24 25 #pragma pack(push, 2) 26 struct X { 27 B a; 28 char b; 29 int c; XX30 X() { 31 printf("X = %d\n", (int)((char*)this - buffer)); 32 printf("X.a = %d\n", (int)((char*)&a - buffer)); 33 printf("X.b = %d\n", (int)((char*)&b - buffer)); 34 printf("X.c = %d\n", (int)((char*)&c - buffer)); 35 } 36 }; 37 38 // CHECK: *** Dumping AST Record Layout 39 // CHECK: *** Dumping AST Record Layout 40 // CHECK-NEXT: 0 | struct X 41 // CHECK-NEXT: 0 | struct B a 42 // CHECK-NEXT: 0 | long long a 43 // CHECK-NEXT: 8 | char b 44 // CHECK-NEXT: 10 | int c 45 // CHECK-NEXT: | [sizeof=16, align=4 46 // CHECK-NEXT: | nvsize=14, nvalign=4] 47 // CHECK-X64: *** Dumping AST Record Layout 48 // CHECK-X64: *** Dumping AST Record Layout 49 // CHECK-X64-NEXT: 0 | struct X 50 // CHECK-X64-NEXT: 0 | struct B a 51 // CHECK-X64-NEXT: 0 | long long a 52 // CHECK-X64-NEXT: 8 | char b 53 // CHECK-X64-NEXT: 10 | int c 54 // CHECK-X64-NEXT: | [sizeof=16, align=4 55 // CHECK-X64-NEXT: | nvsize=14, nvalign=4] 56 57 struct Y : A, B { 58 char a; 59 int b; YY60 Y() { 61 printf("Y = %d\n", (int)((char*)this - buffer)); 62 printf("Y.a = %d\n", (int)((char*)&a - buffer)); 63 printf("Y.b = %d\n", (int)((char*)&b - buffer)); 64 } 65 }; 66 67 // CHECK: *** Dumping AST Record Layout 68 // CHECK: *** Dumping AST Record Layout 69 // CHECK-NEXT: 0 | struct Y 70 // CHECK-NEXT: 0 | struct A (base) 71 // CHECK-NEXT: 0 | char a 72 // CHECK-NEXT: 4 | struct B (base) 73 // CHECK-NEXT: 4 | long long a 74 // CHECK-NEXT: 12 | char a 75 // CHECK-NEXT: 14 | int b 76 // CHECK-NEXT: | [sizeof=20, align=4 77 // CHECK-NEXT: | nvsize=18, nvalign=4] 78 // CHECK-X64: *** Dumping AST Record Layout 79 // CHECK-X64: *** Dumping AST Record Layout 80 // CHECK-X64-NEXT: 0 | struct Y 81 // CHECK-X64-NEXT: 0 | struct A (base) 82 // CHECK-X64-NEXT: 0 | char a 83 // CHECK-X64-NEXT: 4 | struct B (base) 84 // CHECK-X64-NEXT: 4 | long long a 85 // CHECK-X64-NEXT: 12 | char a 86 // CHECK-X64-NEXT: 14 | int b 87 // CHECK-X64-NEXT: | [sizeof=20, align=4 88 // CHECK-X64-NEXT: | nvsize=18, nvalign=4] 89 90 struct Z : virtual B { 91 char a; 92 int b; ZZ93 Z() { 94 printf("Z = %d\n", (int)((char*)this - buffer)); 95 printf("Z.a = %d\n", (int)((char*)&a - buffer)); 96 printf("Z.b = %d\n", (int)((char*)&b - buffer)); 97 } 98 }; 99 100 // CHECK: *** Dumping AST Record Layout 101 // CHECK-NEXT: 0 | struct Z 102 // CHECK-NEXT: 0 | (Z vbtable pointer) 103 // CHECK-NEXT: 4 | char a 104 // CHECK-NEXT: 6 | int b 105 // CHECK-NEXT: 12 | struct B (virtual base) 106 // CHECK-NEXT: 12 | long long a 107 // CHECK-NEXT: | [sizeof=20, align=4 108 // CHECK-NEXT: | nvsize=10, nvalign=4] 109 // CHECK-X64: *** Dumping AST Record Layout 110 // CHECK-X64-NEXT: 0 | struct Z 111 // CHECK-X64-NEXT: 0 | (Z vbtable pointer) 112 // CHECK-X64-NEXT: 8 | char a 113 // CHECK-X64-NEXT: 10 | int b 114 // CHECK-X64-NEXT: 16 | struct B (virtual base) 115 // CHECK-X64-NEXT: 16 | long long a 116 // CHECK-X64-NEXT: | [sizeof=24, align=4 117 // CHECK-X64-NEXT: | nvsize=14, nvalign=4] 118 119 #pragma pack(pop) 120 121 struct A1 { long long a; }; 122 #pragma pack(push, 1) 123 struct B1 : virtual A1 { char a; }; 124 #pragma pack(pop) 125 struct C1 : B1 {}; 126 127 // CHECK: *** Dumping AST Record Layout 128 // CHECK: *** Dumping AST Record Layout 129 // CHECK: *** Dumping AST Record Layout 130 // CHECK-NEXT: 0 | struct C1 131 // CHECK-NEXT: 0 | struct B1 (base) 132 // CHECK-NEXT: 0 | (B1 vbtable pointer) 133 // CHECK-NEXT: 4 | char a 134 // CHECK-NEXT: 8 | struct A1 (virtual base) 135 // CHECK-NEXT: 8 | long long a 136 // CHECK-NEXT: | [sizeof=16, align=8 137 // CHECK-NEXT: | nvsize=5, nvalign=8] 138 // CHECK-X64: *** Dumping AST Record Layout 139 // CHECK-X64: *** Dumping AST Record Layout 140 // CHECK-X64: *** Dumping AST Record Layout 141 // CHECK-X64-NEXT: 0 | struct C1 142 // CHECK-X64-NEXT: 0 | struct B1 (base) 143 // CHECK-X64-NEXT: 0 | (B1 vbtable pointer) 144 // CHECK-X64-NEXT: 8 | char a 145 // CHECK-X64-NEXT: 16 | struct A1 (virtual base) 146 // CHECK-X64-NEXT: 16 | long long a 147 // CHECK-X64-NEXT: | [sizeof=24, align=8 148 // CHECK-X64-NEXT: | nvsize=9, nvalign=8] 149 150 struct CA0 { CA0CA0151 CA0() {} 152 }; 153 struct CA1 : virtual CA0 { CA1CA1154 CA1() {} 155 }; 156 #pragma pack(push, 1) 157 struct CA2 : public CA1, public CA0 { CA2MethodCA2158 virtual void CA2Method() {} CA2CA2159 CA2() {} 160 }; 161 #pragma pack(pop) 162 163 // CHECK: *** Dumping AST Record Layout 164 // CHECK: *** Dumping AST Record Layout 165 // CHECK: *** Dumping AST Record Layout 166 // CHECK-NEXT: 0 | struct CA2 167 // CHECK-NEXT: 0 | (CA2 vftable pointer) 168 // CHECK-NEXT: 4 | struct CA1 (base) 169 // CHECK-NEXT: 4 | (CA1 vbtable pointer) 170 // CHECK-NEXT: 9 | struct CA0 (base) (empty) 171 // CHECK-NEXT: 9 | struct CA0 (virtual base) (empty) 172 // CHECK-NEXT: | [sizeof=9, align=1 173 // CHECK-NEXT: | nvsize=9, nvalign=1] 174 // CHECK-X64: *** Dumping AST Record Layout 175 // CHECK-X64: *** Dumping AST Record Layout 176 // CHECK-X64: *** Dumping AST Record Layout 177 // CHECK-X64-NEXT: 0 | struct CA2 178 // CHECK-X64-NEXT: 0 | (CA2 vftable pointer) 179 // CHECK-X64-NEXT: 8 | struct CA1 (base) 180 // CHECK-X64-NEXT: 8 | (CA1 vbtable pointer) 181 // CHECK-X64-NEXT: 17 | struct CA0 (base) (empty) 182 // CHECK-X64-NEXT: 17 | struct CA0 (virtual base) (empty) 183 // CHECK-X64-NEXT: | [sizeof=17, align=1 184 // CHECK-X64-NEXT: | nvsize=17, nvalign=1] 185 186 #pragma pack(16) 187 struct YA { 188 __declspec(align(32)) char : 1; 189 }; 190 // CHECK: *** Dumping AST Record Layout 191 // CHECK-NEXT: 0 | struct YA (empty) 192 // CHECK-NEXT:0:0-0 | char 193 // CHECK-NEXT: | [sizeof=32, align=32 194 // CHECK-NEXT: | nvsize=32, nvalign=32] 195 // CHECK-X64: *** Dumping AST Record Layout 196 // CHECK-X64-NEXT: 0 | struct YA (empty) 197 // CHECK-X64-NEXT:0:0-0 | char 198 // CHECK-X64-NEXT: | [sizeof=32, align=32 199 // CHECK-X64-NEXT: | nvsize=32, nvalign=32] 200 201 #pragma pack(1) 202 struct YB { 203 char a; 204 YA b; 205 }; 206 // CHECK: *** Dumping AST Record Layout 207 // CHECK-NEXT: 0 | struct YB 208 // CHECK-NEXT: 0 | char a 209 // CHECK-NEXT: 1 | struct YA b (empty) 210 // CHECK-NEXT:1:0-0 | char 211 // CHECK-NEXT: | [sizeof=33, align=1 212 // CHECK-NEXT: | nvsize=33, nvalign=1] 213 // CHECK-X64: *** Dumping AST Record Layout 214 // CHECK-X64-NEXT: 0 | struct YB 215 // CHECK-X64-NEXT: 0 | char a 216 // CHECK-X64-NEXT: 1 | struct YA b (empty) 217 // CHECK-X64-NEXT:1:0-0 | char 218 // CHECK-X64-NEXT: | [sizeof=33, align=1 219 // CHECK-X64-NEXT: | nvsize=33, nvalign=1] 220 221 #pragma pack(8) 222 struct YC { 223 __declspec(align(32)) char : 1; 224 }; 225 // CHECK: *** Dumping AST Record Layout 226 // CHECK-NEXT: 0 | struct YC (empty) 227 // CHECK-NEXT:0:0-0 | char 228 // CHECK-NEXT: | [sizeof=32, align=32 229 // CHECK-NEXT: | nvsize=32, nvalign=32] 230 // CHECK-X64: *** Dumping AST Record Layout 231 // CHECK-X64-NEXT: 0 | struct YC (empty) 232 // CHECK-X64-NEXT: 0:0-0 | char 233 // CHECK-X64-NEXT: | [sizeof=8, align=32 234 // CHECK-X64-NEXT: | nvsize=8, nvalign=32] 235 236 #pragma pack(1) 237 struct YD { 238 char a; 239 YC b; 240 }; 241 // CHECK: *** Dumping AST Record Layout 242 // CHECK-NEXT: 0 | struct YD 243 // CHECK-NEXT: 0 | char a 244 // CHECK-NEXT: 1 | struct YC b (empty) 245 // CHECK-NEXT:1:0-0 | char 246 // CHECK-NEXT: | [sizeof=33, align=1 247 // CHECK-NEXT: | nvsize=33, nvalign=1] 248 // CHECK-X64: *** Dumping AST Record Layout 249 // CHECK-X64-NEXT: 0 | struct YD 250 // CHECK-X64-NEXT: 0 | char a 251 // CHECK-X64-NEXT: 1 | struct YC b (empty) 252 // CHECK-X64-NEXT:1:0-0 | char 253 // CHECK-X64-NEXT: | [sizeof=9, align=1 254 // CHECK-X64-NEXT: | nvsize=9, nvalign=1] 255 256 #pragma pack(4) 257 struct YE { 258 __declspec(align(32)) char : 1; 259 }; 260 // CHECK: *** Dumping AST Record Layout 261 // CHECK-NEXT: 0 | struct YE (empty) 262 // CHECK-NEXT: 0:0-0 | char 263 // CHECK-NEXT: | [sizeof=4, align=32 264 // CHECK-NEXT: | nvsize=4, nvalign=32] 265 // CHECK-X64: *** Dumping AST Record Layout 266 // CHECK-X64-NEXT: 0 | struct YE (empty) 267 // CHECK-X64-NEXT: 0:0-0 | char 268 // CHECK-X64-NEXT: | [sizeof=4, align=32 269 // CHECK-X64-NEXT: | nvsize=4, nvalign=32] 270 271 #pragma pack(1) 272 struct YF { 273 char a; 274 YE b; 275 }; 276 // CHECK: *** Dumping AST Record Layout 277 // CHECK-NEXT: 0 | struct YF 278 // CHECK-NEXT: 0 | char a 279 // CHECK-NEXT: 1 | struct YE b (empty) 280 // CHECK-NEXT:1:0-0 | char 281 // CHECK-NEXT: | [sizeof=5, align=1 282 // CHECK-NEXT: | nvsize=5, nvalign=1] 283 // CHECK-X64: *** Dumping AST Record Layout 284 // CHECK-X64-NEXT: 0 | struct YF 285 // CHECK-X64-NEXT: 0 | char a 286 // CHECK-X64-NEXT: 1 | struct YE b (empty) 287 // CHECK-X64-NEXT:1:0-0 | char 288 // CHECK-X64-NEXT: | [sizeof=5, align=1 289 // CHECK-X64-NEXT: | nvsize=5, nvalign=1] 290 291 #pragma pack(16) 292 struct __declspec(align(16)) D0 { char a; }; 293 #pragma pack(1) 294 struct D1 : public D0 { char a; }; 295 #pragma pack(16) 296 struct D2 : D1 { char a; }; 297 298 // CHECK: *** Dumping AST Record Layout 299 // CHECK: *** Dumping AST Record Layout 300 // CHECK: *** Dumping AST Record Layout 301 // CHECK-NEXT: 0 | struct D2 302 // CHECK-NEXT: 0 | struct D1 (base) 303 // CHECK-NEXT: 0 | struct D0 (base) 304 // CHECK-NEXT: 0 | char a 305 // CHECK-NEXT: 1 | char a 306 // CHECK-NEXT: 2 | char a 307 // CHECK-NEXT: | [sizeof=16, align=16 308 // CHECK-NEXT: | nvsize=16, nvalign=16] 309 // CHECK-X64: *** Dumping AST Record Layout 310 // CHECK-X64: *** Dumping AST Record Layout 311 // CHECK-X64: *** Dumping AST Record Layout 312 // CHECK-X64-NEXT: 0 | struct D2 313 // CHECK-X64-NEXT: 0 | struct D1 (base) 314 // CHECK-X64-NEXT: 0 | struct D0 (base) 315 // CHECK-X64-NEXT: 0 | char a 316 // CHECK-X64-NEXT: 1 | char a 317 // CHECK-X64-NEXT: 2 | char a 318 // CHECK-X64-NEXT: | [sizeof=16, align=16 319 // CHECK-X64-NEXT: | nvsize=16, nvalign=16] 320 321 #pragma pack() 322 struct JA { char a; }; 323 #pragma pack(1) 324 struct JB { __declspec(align(4)) char a; }; 325 #pragma pack() 326 struct JC : JB, JA { }; 327 328 // CHECK: *** Dumping AST Record Layout 329 // CHECK: *** Dumping AST Record Layout 330 // CHECK: *** Dumping AST Record Layout 331 // CHECK-NEXT: 0 | struct JC 332 // CHECK-NEXT: 0 | struct JB (base) 333 // CHECK-NEXT: 0 | char a 334 // CHECK-NEXT: 1 | struct JA (base) 335 // CHECK-NEXT: 1 | char a 336 // CHECK-NEXT: | [sizeof=4, align=4 337 // CHECK-NEXT: | nvsize=4, nvalign=4] 338 // CHECK-X64: *** Dumping AST Record Layout 339 // CHECK-X64: *** Dumping AST Record Layout 340 // CHECK-X64: *** Dumping AST Record Layout 341 // CHECK-X64-NEXT: 0 | struct JC 342 // CHECK-X64-NEXT: 0 | struct JB (base) 343 // CHECK-X64-NEXT: 0 | char a 344 // CHECK-X64-NEXT: 1 | struct JA (base) 345 // CHECK-X64-NEXT: 1 | char a 346 // CHECK-X64-NEXT: | [sizeof=4, align=4 347 // CHECK-X64-NEXT: | nvsize=4, nvalign=4] 348 349 #pragma pack() 350 struct KA { char a; }; 351 #pragma pack(1) 352 struct KB : KA { __declspec(align(2)) char a; }; 353 354 // CHECK: *** Dumping AST Record Layout 355 // CHECK: *** Dumping AST Record Layout 356 // CHECK-NEXT: 0 | struct KB 357 // CHECK-NEXT: 0 | struct KA (base) 358 // CHECK-NEXT: 0 | char a 359 // CHECK-NEXT: 2 | char a 360 // CHECK-NEXT: | [sizeof=4, align=2 361 // CHECK-NEXT: | nvsize=3, nvalign=2] 362 // CHECK-X64: *** Dumping AST Record Layout 363 // CHECK-X64: *** Dumping AST Record Layout 364 // CHECK-X64-NEXT: 0 | struct KB 365 // CHECK-X64-NEXT: 0 | struct KA (base) 366 // CHECK-X64-NEXT: 0 | char a 367 // CHECK-X64-NEXT: 2 | char a 368 // CHECK-X64-NEXT: | [sizeof=4, align=2 369 // CHECK-X64-NEXT: | nvsize=3, nvalign=2] 370 371 #pragma pack(1) 372 struct L { funL373 virtual void fun() {} 374 __declspec(align(256)) int Field; 375 }; 376 377 // CHECK: *** Dumping AST Record Layout 378 // CHECK-NEXT: 0 | struct L 379 // CHECK-NEXT: 0 | (L vftable pointer) 380 // CHECK-NEXT: 256 | int Field 381 // CHECK-NEXT: | [sizeof=512, align=256 382 // CHECK-NEXT: | nvsize=260, nvalign=256] 383 // CHECK-X64: *** Dumping AST Record Layout 384 // CHECK-X64-NEXT: 0 | struct L 385 // CHECK-X64-NEXT: 0 | (L vftable pointer) 386 // CHECK-X64-NEXT: 256 | int Field 387 // CHECK-X64-NEXT: | [sizeof=512, align=256 388 // CHECK-X64-NEXT: | nvsize=260, nvalign=256] 389 390 #pragma pack() 391 struct MA {}; 392 #pragma pack(1) 393 struct MB : virtual MA { 394 __declspec(align(256)) int Field; 395 }; 396 397 // CHECK: *** Dumping AST Record Layout 398 // CHECK: *** Dumping AST Record Layout 399 // CHECK-NEXT: 0 | struct MB 400 // CHECK-NEXT: 0 | (MB vbtable pointer) 401 // CHECK-NEXT: 256 | int Field 402 // CHECK-NEXT: 260 | struct MA (virtual base) (empty) 403 // CHECK-NEXT: | [sizeof=512, align=256 404 // CHECK-NEXT: | nvsize=260, nvalign=256] 405 // CHECK-X64: *** Dumping AST Record Layout 406 // CHECK-X64: *** Dumping AST Record Layout 407 // CHECK-X64-NEXT: 0 | struct MB 408 // CHECK-X64-NEXT: 0 | (MB vbtable pointer) 409 // CHECK-X64-NEXT: 256 | int Field 410 // CHECK-X64-NEXT: 260 | struct MA (virtual base) (empty) 411 // CHECK-X64-NEXT: | [sizeof=512, align=256 412 // CHECK-X64-NEXT: | nvsize=260, nvalign=256] 413 414 struct RA {}; 415 #pragma pack(1) 416 struct __declspec(align(8)) RB0 { 417 __declspec(align(1024)) int b : 3; 418 }; 419 420 struct __declspec(align(8)) RB1 { 421 __declspec(align(1024)) int b : 3; fRB1422 virtual void f() {} 423 }; 424 425 struct __declspec(align(8)) RB2 : virtual RA { 426 __declspec(align(1024)) int b : 3; 427 }; 428 429 struct __declspec(align(8)) RB3 : virtual RA { 430 __declspec(align(1024)) int b : 3; fRB3431 virtual void f() {} 432 }; 433 434 struct RC { 435 char _; 436 __declspec(align(1024)) int c : 3; 437 }; 438 struct RE { 439 char _; 440 RC c; 441 }; 442 #pragma pack() 443 444 // CHECK: *** Dumping AST Record Layout 445 // CHECK-NEXT: 0 | struct RB0 446 // CHECK-NEXT:0:0-2 | int b 447 // CHECK-NEXT: | [sizeof=8, align=1024 448 // CHECK-NEXT: | nvsize=4, nvalign=1024] 449 // CHECK: *** Dumping AST Record Layout 450 // CHECK-NEXT: 0 | struct RB1 451 // CHECK-NEXT: 0 | (RB1 vftable pointer) 452 // CHECK-NEXT: 1024:0-2 | int b 453 // CHECK-NEXT: | [sizeof=1032, align=1024 454 // CHECK-NEXT: | nvsize=1028, nvalign=1024] 455 // CHECK: *** Dumping AST Record Layout 456 // CHECK: *** Dumping AST Record Layout 457 // CHECK-NEXT: 0 | struct RB2 458 // CHECK-NEXT: 0 | (RB2 vbtable pointer) 459 // CHECK-NEXT: 1024:0-2 | int b 460 // CHECK-NEXT: 1028 | struct RA (virtual base) (empty) 461 // CHECK-NEXT: | [sizeof=1032, align=1024 462 // CHECK-NEXT: | nvsize=1028, nvalign=1024] 463 // CHECK: *** Dumping AST Record Layout 464 // CHECK-NEXT: 0 | struct RB3 465 // CHECK-NEXT: 0 | (RB3 vftable pointer) 466 // CHECK-NEXT: 1024 | (RB3 vbtable pointer) 467 // CHECK-NEXT: 2048:0-2 | int b 468 // CHECK-NEXT: 2052 | struct RA (virtual base) (empty) 469 // CHECK-NEXT: | [sizeof=2056, align=1024 470 // CHECK-NEXT: | nvsize=2052, nvalign=1024] 471 // CHECK: *** Dumping AST Record Layout 472 // CHECK-NEXT: 0 | struct RC 473 // CHECK-NEXT: 0 | char _ 474 // CHECK-NEXT: 1024:0-2 | int c 475 // CHECK-NEXT: | [sizeof=1028, align=1024 476 // CHECK-NEXT: | nvsize=1028, nvalign=1024] 477 // CHECK: *** Dumping AST Record Layout 478 // CHECK-NEXT: 0 | struct RE 479 // CHECK-NEXT: 0 | char _ 480 // CHECK-NEXT: 1 | struct RC c 481 // CHECK-NEXT: 1 | char _ 482 // CHECK-NEXT: 1025:0-2 | int c 483 // CHECK-NEXT: | [sizeof=1029, align=1 484 // CHECK-NEXT: | nvsize=1029, nvalign=1] 485 // CHECK-X64: *** Dumping AST Record Layout 486 // CHECK-X64-NEXT: 0 | struct RB0 487 // CHECK-X64-NEXT: 0:0-2 | int b 488 // CHECK-X64-NEXT: | [sizeof=8, align=1024 489 // CHECK-X64-NEXT: | nvsize=4, nvalign=1024] 490 // CHECK-X64: *** Dumping AST Record Layout 491 // CHECK-X64-NEXT: 0 | struct RB1 492 // CHECK-X64-NEXT: 0 | (RB1 vftable pointer) 493 // CHECK-X64-NEXT: 1024:0-2 | int b 494 // CHECK-X64-NEXT: | [sizeof=1032, align=1024 495 // CHECK-X64-NEXT: | nvsize=1028, nvalign=1024] 496 // CHECK-X64: *** Dumping AST Record Layout 497 // CHECK-X64: *** Dumping AST Record Layout 498 // CHECK-X64-NEXT: 0 | struct RB2 499 // CHECK-X64-NEXT: 0 | (RB2 vbtable pointer) 500 // CHECK-X64-NEXT: 1024:0-2 | int b 501 // CHECK-X64-NEXT: 1028 | struct RA (virtual base) (empty) 502 // CHECK-X64-NEXT: | [sizeof=1032, align=1024 503 // CHECK-X64-NEXT: | nvsize=1028, nvalign=1024] 504 // CHECK-X64: *** Dumping AST Record Layout 505 // CHECK-X64-NEXT: 0 | struct RB3 506 // CHECK-X64-NEXT: 0 | (RB3 vftable pointer) 507 // CHECK-X64-NEXT: 1024 | (RB3 vbtable pointer) 508 // CHECK-X64-NEXT: 2048:0-2 | int b 509 // CHECK-X64-NEXT: 2052 | struct RA (virtual base) (empty) 510 // CHECK-X64-NEXT: | [sizeof=2056, align=1024 511 // CHECK-X64-NEXT: | nvsize=2052, nvalign=1024] 512 // CHECK-X64: *** Dumping AST Record Layout 513 // CHECK-X64-NEXT: 0 | struct RC 514 // CHECK-X64-NEXT: 0 | char _ 515 // CHECK-X64-NEXT: 1024:0-2 | int c 516 // CHECK-X64-NEXT: | [sizeof=1028, align=1024 517 // CHECK-X64-NEXT: | nvsize=1028, nvalign=1024] 518 // CHECK-X64: *** Dumping AST Record Layout 519 // CHECK-X64-NEXT: 0 | struct RE 520 // CHECK-X64-NEXT: 0 | char _ 521 // CHECK-X64-NEXT: 1 | struct RC c 522 // CHECK-X64-NEXT: 1 | char _ 523 // CHECK-X64-NEXT: 1025:0-2 | int c 524 // CHECK-X64-NEXT: | [sizeof=1029, align=1 525 // CHECK-X64-NEXT: | nvsize=1029, nvalign=1] 526 527 struct NA {}; 528 struct NB {}; 529 #pragma pack(push, 1) 530 struct NC : virtual NA, virtual NB {}; 531 #pragma pack(pop) 532 struct ND : NC {}; 533 534 // CHECK: *** Dumping AST Record Layout 535 // CHECK-NEXT: 0 | struct NA (empty) 536 // CHECK-NEXT: | [sizeof=1, align=1 537 // CHECK-NEXT: | nvsize=0, nvalign=1] 538 // CHECK: *** Dumping AST Record Layout 539 // CHECK-NEXT: 0 | struct NB (empty) 540 // CHECK-NEXT: | [sizeof=1, align=1 541 // CHECK-NEXT: | nvsize=0, nvalign=1] 542 // CHECK: *** Dumping AST Record Layout 543 // CHECK-NEXT: 0 | struct NC 544 // CHECK-NEXT: 0 | (NC vbtable pointer) 545 // CHECK-NEXT: 4 | struct NA (virtual base) (empty) 546 // CHECK-NEXT: 8 | struct NB (virtual base) (empty) 547 // CHECK-NEXT: | [sizeof=8, align=1 548 // CHECK-NEXT: | nvsize=4, nvalign=1] 549 // CHECK: *** Dumping AST Record Layout 550 // CHECK-NEXT: 0 | struct ND 551 // CHECK-NEXT: 0 | struct NC (base) 552 // CHECK-NEXT: 0 | (NC vbtable pointer) 553 // CHECK-NEXT: 4 | struct NA (virtual base) (empty) 554 // CHECK-NEXT: 8 | struct NB (virtual base) (empty) 555 // CHECK-NEXT: | [sizeof=8, align=4 556 // CHECK-NEXT: | nvsize=4, nvalign=4] 557 // CHECK-X64: *** Dumping AST Record Layout 558 // CHECK-X64-NEXT: 0 | struct NA (empty) 559 // CHECK-X64-NEXT: | [sizeof=1, align=1 560 // CHECK-X64-NEXT: | nvsize=0, nvalign=1] 561 // CHECK-X64: *** Dumping AST Record Layout 562 // CHECK-X64-NEXT: 0 | struct NB (empty) 563 // CHECK-X64-NEXT: | [sizeof=1, align=1 564 // CHECK-X64-NEXT: | nvsize=0, nvalign=1] 565 // CHECK-X64: *** Dumping AST Record Layout 566 // CHECK-X64-NEXT: 0 | struct NC 567 // CHECK-X64-NEXT: 0 | (NC vbtable pointer) 568 // CHECK-X64-NEXT: 8 | struct NA (virtual base) (empty) 569 // CHECK-X64-NEXT: 12 | struct NB (virtual base) (empty) 570 // CHECK-X64-NEXT: | [sizeof=12, align=1 571 // CHECK-X64-NEXT: | nvsize=8, nvalign=1] 572 // CHECK-X64: *** Dumping AST Record Layout 573 // CHECK-X64-NEXT: 0 | struct ND 574 // CHECK-X64-NEXT: 0 | struct NC (base) 575 // CHECK-X64-NEXT: 0 | (NC vbtable pointer) 576 // CHECK-X64-NEXT: 8 | struct NA (virtual base) (empty) 577 // CHECK-X64-NEXT: 12 | struct NB (virtual base) (empty) 578 // CHECK-X64-NEXT: | [sizeof=12, align=4 579 // CHECK-X64-NEXT: | nvsize=8, nvalign=4] 580 581 struct OA {}; 582 struct OB {}; 583 struct OC : virtual OA, virtual OB {}; 584 #pragma pack(push, 1) 585 struct OD : OC {}; 586 #pragma pack(pop) 587 588 // CHECK: *** Dumping AST Record Layout 589 // CHECK-NEXT: 0 | struct OA (empty) 590 // CHECK-NEXT: | [sizeof=1, align=1 591 // CHECK-NEXT: | nvsize=0, nvalign=1] 592 // CHECK: *** Dumping AST Record Layout 593 // CHECK-NEXT: 0 | struct OB (empty) 594 // CHECK-NEXT: | [sizeof=1, align=1 595 // CHECK-NEXT: | nvsize=0, nvalign=1] 596 // CHECK: *** Dumping AST Record Layout 597 // CHECK-NEXT: 0 | struct OC 598 // CHECK-NEXT: 0 | (OC vbtable pointer) 599 // CHECK-NEXT: 4 | struct OA (virtual base) (empty) 600 // CHECK-NEXT: 8 | struct OB (virtual base) (empty) 601 // CHECK-NEXT: | [sizeof=8, align=4 602 // CHECK-NEXT: | nvsize=4, nvalign=4] 603 // CHECK: *** Dumping AST Record Layout 604 // CHECK-NEXT: 0 | struct OD 605 // CHECK-NEXT: 0 | struct OC (base) 606 // CHECK-NEXT: 0 | (OC vbtable pointer) 607 // CHECK-NEXT: 4 | struct OA (virtual base) (empty) 608 // CHECK-NEXT: 8 | struct OB (virtual base) (empty) 609 // CHECK-NEXT: | [sizeof=8, align=1 610 // CHECK-NEXT: | nvsize=4, nvalign=1] 611 // CHECK-X64: *** Dumping AST Record Layout 612 // CHECK-X64-NEXT: 0 | struct OA (empty) 613 // CHECK-X64-NEXT: | [sizeof=1, align=1 614 // CHECK-X64-NEXT: | nvsize=0, nvalign=1] 615 // CHECK-X64: *** Dumping AST Record Layout 616 // CHECK-X64-NEXT: 0 | struct OB (empty) 617 // CHECK-X64-NEXT: | [sizeof=1, align=1 618 // CHECK-X64-NEXT: | nvsize=0, nvalign=1] 619 // CHECK-X64: *** Dumping AST Record Layout 620 // CHECK-X64-NEXT: 0 | struct OC 621 // CHECK-X64-NEXT: 0 | (OC vbtable pointer) 622 // CHECK-X64-NEXT: 8 | struct OA (virtual base) (empty) 623 // CHECK-X64-NEXT: 12 | struct OB (virtual base) (empty) 624 // CHECK-X64-NEXT: | [sizeof=16, align=8 625 // CHECK-X64-NEXT: | nvsize=8, nvalign=8] 626 // CHECK-X64: *** Dumping AST Record Layout 627 // CHECK-X64-NEXT: 0 | struct OD 628 // CHECK-X64-NEXT: 0 | struct OC (base) 629 // CHECK-X64-NEXT: 0 | (OC vbtable pointer) 630 // CHECK-X64-NEXT: 8 | struct OA (virtual base) (empty) 631 // CHECK-X64-NEXT: 12 | struct OB (virtual base) (empty) 632 // CHECK-X64-NEXT: | [sizeof=12, align=1 633 // CHECK-X64-NEXT: | nvsize=8, nvalign=1] 634 635 struct __declspec(align(4)) PA { 636 int c; 637 }; 638 639 typedef __declspec(align(8)) PA PB; 640 641 #pragma pack(push, 1) 642 struct PC { 643 char a; 644 PB x; 645 }; 646 #pragma pack(pop) 647 648 // CHECK: *** Dumping AST Record Layout 649 // CHECK: 0 | struct PC 650 // CHECK-NEXT: 0 | char a 651 // CHECK-NEXT: 8 | struct PA x 652 // CHECK-NEXT: 8 | int c 653 // CHECK-NEXT: | [sizeof=16, align=8 654 // CHECK-NEXT: | nvsize=12, nvalign=8] 655 // CHECK-X64: *** Dumping AST Record Layout 656 // CHECK-X64: 0 | struct PC 657 // CHECK-X64-NEXT: 0 | char a 658 // CHECK-X64-NEXT: 8 | struct PA x 659 // CHECK-X64-NEXT: 8 | int c 660 // CHECK-X64-NEXT: | [sizeof=16, align=8 661 // CHECK-X64-NEXT: | nvsize=12, nvalign=8] 662 663 typedef PB PD; 664 665 #pragma pack(push, 1) 666 struct PE { 667 char a; 668 PD x; 669 }; 670 #pragma pack(pop) 671 672 // CHECK: *** Dumping AST Record Layout 673 // CHECK: 0 | struct PE 674 // CHECK-NEXT: 0 | char a 675 // CHECK-NEXT: 8 | struct PA x 676 // CHECK-NEXT: 8 | int c 677 // CHECK-NEXT: | [sizeof=16, align=8 678 // CHECK-NEXT: | nvsize=12, nvalign=8] 679 // CHECK-X64: *** Dumping AST Record Layout 680 // CHECK-X64: 0 | struct PE 681 // CHECK-X64-NEXT: 0 | char a 682 // CHECK-X64-NEXT: 8 | struct PA x 683 // CHECK-X64-NEXT: 8 | int c 684 // CHECK-X64-NEXT: | [sizeof=16, align=8 685 // CHECK-X64-NEXT: | nvsize=12, nvalign=8] 686 687 typedef int __declspec(align(2)) QA; 688 #pragma pack(push, 1) 689 struct QB { 690 char a; 691 QA b; 692 }; 693 #pragma pack(pop) 694 695 // CHECK: *** Dumping AST Record Layout 696 // CHECK-NEXT: 0 | struct QB 697 // CHECK-NEXT: 0 | char a 698 // CHECK-NEXT: 2 | QA b 699 // CHECK-NEXT: | [sizeof=6, align=2 700 // CHECK-NEXT: | nvsize=6, nvalign=2] 701 // CHECK-X64: *** Dumping AST Record Layout 702 // CHECK-X64-NEXT: 0 | struct QB 703 // CHECK-X64-NEXT: 0 | char a 704 // CHECK-X64-NEXT: 2 | QA b 705 // CHECK-X64-NEXT: | [sizeof=6, align=2 706 // CHECK-X64-NEXT: | nvsize=6, nvalign=2] 707 708 struct QC { 709 char a; 710 QA b; 711 }; 712 713 // CHECK: *** Dumping AST Record Layout 714 // CHECK-NEXT: 0 | struct QC 715 // CHECK-NEXT: 0 | char a 716 // CHECK-NEXT: 4 | QA b 717 // CHECK-NEXT: | [sizeof=8, align=4 718 // CHECK-NEXT: | nvsize=8, nvalign=4] 719 // CHECK-X64: *** Dumping AST Record Layout 720 // CHECK-X64-NEXT: 0 | struct QC 721 // CHECK-X64-NEXT: 0 | char a 722 // CHECK-X64-NEXT: 4 | QA b 723 // CHECK-X64-NEXT: | [sizeof=8, align=4 724 // CHECK-X64-NEXT: | nvsize=8, nvalign=4] 725 726 struct QD { 727 char a; 728 QA b : 3; 729 }; 730 731 // CHECK: *** Dumping AST Record Layout 732 // CHECK-NEXT: 0 | struct QD 733 // CHECK-NEXT: 0 | char a 734 // CHECK-NEXT:4:0-2 | QA b 735 // CHECK-NEXT: | [sizeof=8, align=4 736 // CHECK-NEXT: | nvsize=8, nvalign=4] 737 // CHECK-X64: *** Dumping AST Record Layout 738 // CHECK-X64-NEXT: 0 | struct QD 739 // CHECK-X64-NEXT: 0 | char a 740 // CHECK-X64-NEXT:4:0-2 | QA b 741 // CHECK-X64-NEXT: | [sizeof=8, align=4 742 // CHECK-X64-NEXT: | nvsize=8, nvalign=4] 743 744 struct __declspec(align(4)) EmptyAlignedLongLongMemb { 745 long long FlexArrayMemb[0]; 746 }; 747 748 // CHECK: *** Dumping AST Record Layout 749 // CHECK-NEXT: 0 | struct EmptyAlignedLongLongMemb 750 // CHECK-NEXT: 0 | long long [0] FlexArrayMemb 751 // CHECK-NEXT: | [sizeof=8, align=8 752 // CHECK-NEXT: | nvsize=0, nvalign=8] 753 // CHECK-X64: *** Dumping AST Record Layout 754 // CHECK-X64-NEXT: 0 | struct EmptyAlignedLongLongMemb 755 // CHECK-X64-NEXT: 0 | long long [0] FlexArrayMemb 756 // CHECK-X64-NEXT: | [sizeof=8, align=8 757 // CHECK-X64-NEXT: | nvsize=0, nvalign=8] 758 759 #pragma pack(1) 760 struct __declspec(align(4)) EmptyPackedAlignedLongLongMemb { 761 long long FlexArrayMemb[0]; 762 }; 763 #pragma pack() 764 765 // CHECK: *** Dumping AST Record Layout 766 // CHECK-NEXT: 0 | struct EmptyPackedAlignedLongLongMemb 767 // CHECK-NEXT: 0 | long long [0] FlexArrayMemb 768 // CHECK-NEXT: | [sizeof=4, align=4 769 // CHECK-NEXT: | nvsize=0, nvalign=4] 770 // CHECK-X64: *** Dumping AST Record Layout 771 // CHECK-X64-NEXT: 0 | struct EmptyPackedAlignedLongLongMemb 772 // CHECK-X64-NEXT: 0 | long long [0] FlexArrayMemb 773 // CHECK-X64-NEXT: | [sizeof=4, align=4 774 // CHECK-X64-NEXT: | nvsize=0, nvalign=4] 775 776 int a[ 777 sizeof(X)+ 778 sizeof(Y)+ 779 sizeof(Z)+ 780 sizeof(C1)+ 781 sizeof(CA2)+ 782 sizeof(YA)+ 783 sizeof(YB)+ 784 sizeof(YC)+ 785 sizeof(YD)+ 786 sizeof(YE)+ 787 sizeof(YF)+ 788 sizeof(YF)+ 789 sizeof(D2)+ 790 sizeof(JC)+ 791 sizeof(KB)+ 792 sizeof(L)+ 793 sizeof(MB)+ 794 sizeof(RB0)+ 795 sizeof(RB1)+ 796 sizeof(RB2)+ 797 sizeof(RB3)+ 798 sizeof(RC)+ 799 sizeof(RE)+ 800 sizeof(ND)+ 801 sizeof(OD)+ 802 sizeof(PC)+ 803 sizeof(PE)+ 804 sizeof(QB)+ 805 sizeof(QC)+ 806 sizeof(QD)+ 807 sizeof(EmptyAlignedLongLongMemb)+ 808 sizeof(EmptyPackedAlignedLongLongMemb)+ 809 0]; 810