1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fms-extensions -fdump-record-layouts %s 2>/dev/null \ 2f4a2713aSLionel Sambuc // RUN: | FileCheck %s 3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fms-extensions -fdump-record-layouts %s 2>/dev/null \ 4f4a2713aSLionel Sambuc // RUN: | FileCheck %s 5f4a2713aSLionel Sambuc 6f4a2713aSLionel Sambuc typedef struct A { 7f4a2713aSLionel Sambuc char x; 8f4a2713aSLionel Sambuc int a : 22; 9f4a2713aSLionel Sambuc int : 0; 10f4a2713aSLionel Sambuc int c : 10; 11f4a2713aSLionel Sambuc char b : 3; 12f4a2713aSLionel Sambuc char d: 4; 13f4a2713aSLionel Sambuc short y; 14f4a2713aSLionel Sambuc } A; 15f4a2713aSLionel Sambuc 16f4a2713aSLionel Sambuc // CHECK: Type: struct A 17f4a2713aSLionel Sambuc // CHECK: Size:128 18f4a2713aSLionel Sambuc // CHECK: Alignment:32 19f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 32, 64, 64, 96, 99, 112]> 20f4a2713aSLionel Sambuc 21f4a2713aSLionel Sambuc typedef struct B { 22f4a2713aSLionel Sambuc char x; 23f4a2713aSLionel Sambuc int : 0; 24f4a2713aSLionel Sambuc short a : 4; 25f4a2713aSLionel Sambuc char y; 26f4a2713aSLionel Sambuc } B; 27f4a2713aSLionel Sambuc 28f4a2713aSLionel Sambuc // CHECK: Type: struct B 29f4a2713aSLionel Sambuc // CHECK: Size:48 30f4a2713aSLionel Sambuc // CHECK: Alignment:16 31f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 8, 16, 32]> 32f4a2713aSLionel Sambuc 33f4a2713aSLionel Sambuc typedef struct C { 34f4a2713aSLionel Sambuc char x; 35f4a2713aSLionel Sambuc short a : 4; 36f4a2713aSLionel Sambuc int : 0; 37f4a2713aSLionel Sambuc char y; 38f4a2713aSLionel Sambuc } C; 39f4a2713aSLionel Sambuc 40f4a2713aSLionel Sambuc // CHECK: Type: struct C 41f4a2713aSLionel Sambuc // CHECK: Size:64 42f4a2713aSLionel Sambuc // CHECK: Alignment:32 43f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 16, 32, 32]> 44f4a2713aSLionel Sambuc 45f4a2713aSLionel Sambuc typedef struct D { 46f4a2713aSLionel Sambuc char x; 47f4a2713aSLionel Sambuc short : 0; 48f4a2713aSLionel Sambuc int : 0; 49f4a2713aSLionel Sambuc char y; 50f4a2713aSLionel Sambuc } D; 51f4a2713aSLionel Sambuc 52f4a2713aSLionel Sambuc // CHECK: Type: struct D 53f4a2713aSLionel Sambuc // CHECK: Size:16 54f4a2713aSLionel Sambuc // CHECK: Alignment:8 55f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 8, 8, 8]> 56f4a2713aSLionel Sambuc 57f4a2713aSLionel Sambuc typedef union E { 58f4a2713aSLionel Sambuc char x; 59f4a2713aSLionel Sambuc long long a : 3; 60f4a2713aSLionel Sambuc int b : 3; 61f4a2713aSLionel Sambuc long long : 0; 62f4a2713aSLionel Sambuc short y; 63f4a2713aSLionel Sambuc } E; 64f4a2713aSLionel Sambuc 65f4a2713aSLionel Sambuc // CHECK: Type: union E 66f4a2713aSLionel Sambuc // CHECK: Size:64 67f4a2713aSLionel Sambuc // CHECK: Alignment:16 68f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 0, 0, 0, 0]> 69f4a2713aSLionel Sambuc 70f4a2713aSLionel Sambuc typedef struct F { 71f4a2713aSLionel Sambuc char x; 72f4a2713aSLionel Sambuc char a : 3; 73f4a2713aSLionel Sambuc char b : 3; 74f4a2713aSLionel Sambuc char c : 3; 75f4a2713aSLionel Sambuc short d : 6; 76f4a2713aSLionel Sambuc short e : 6; 77f4a2713aSLionel Sambuc short f : 6; 78f4a2713aSLionel Sambuc short g : 11; 79f4a2713aSLionel Sambuc short h : 11; 80f4a2713aSLionel Sambuc short i : 11; 81f4a2713aSLionel Sambuc short y; 82f4a2713aSLionel Sambuc } F; 83f4a2713aSLionel Sambuc 84f4a2713aSLionel Sambuc // CHECK: Type: struct F 85f4a2713aSLionel Sambuc // CHECK: Size:128 86f4a2713aSLionel Sambuc // CHECK: Alignment:16 87f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 8, 11, 16, 32, 38, 48, 64, 80, 96, 112]> 88f4a2713aSLionel Sambuc 89f4a2713aSLionel Sambuc typedef union G { 90f4a2713aSLionel Sambuc char x; 91f4a2713aSLionel Sambuc int a : 3; 92f4a2713aSLionel Sambuc int : 0; 93f4a2713aSLionel Sambuc long long : 0; 94f4a2713aSLionel Sambuc short y; 95f4a2713aSLionel Sambuc } G; 96f4a2713aSLionel Sambuc 97f4a2713aSLionel Sambuc // CHECK: Type: union G 98f4a2713aSLionel Sambuc // CHECK: Size:32 99f4a2713aSLionel Sambuc // CHECK: Alignment:16 100f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 0, 0, 0, 0]> 101f4a2713aSLionel Sambuc 102f4a2713aSLionel Sambuc typedef struct H { 103f4a2713aSLionel Sambuc unsigned short a : 1; 104f4a2713aSLionel Sambuc unsigned char : 0; 105f4a2713aSLionel Sambuc unsigned long : 0; 106f4a2713aSLionel Sambuc unsigned short c : 1; 107f4a2713aSLionel Sambuc } H; 108f4a2713aSLionel Sambuc 109f4a2713aSLionel Sambuc // CHECK: Type: struct H 110f4a2713aSLionel Sambuc // CHECK: Size:32 111f4a2713aSLionel Sambuc // CHECK: Alignment:16 112f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 16, 16, 16]> 113f4a2713aSLionel Sambuc 114*0a6a1f1dSLionel Sambuc typedef struct I { 115*0a6a1f1dSLionel Sambuc short : 8; 116*0a6a1f1dSLionel Sambuc __declspec(align(16)) short : 8; 117*0a6a1f1dSLionel Sambuc } I; 118*0a6a1f1dSLionel Sambuc 119*0a6a1f1dSLionel Sambuc // CHECK: Type: struct I 120*0a6a1f1dSLionel Sambuc // CHECK: Size:16 121*0a6a1f1dSLionel Sambuc // CHECK: Alignment:16 122*0a6a1f1dSLionel Sambuc // CHECK: FieldOffsets: [0, 8] 123*0a6a1f1dSLionel Sambuc 124f4a2713aSLionel Sambuc #pragma pack(push, 1) 125f4a2713aSLionel Sambuc 126f4a2713aSLionel Sambuc typedef struct A1 { 127f4a2713aSLionel Sambuc char x; 128f4a2713aSLionel Sambuc int a : 22; 129f4a2713aSLionel Sambuc int : 0; 130f4a2713aSLionel Sambuc int c : 10; 131f4a2713aSLionel Sambuc char b : 3; 132f4a2713aSLionel Sambuc char d: 4; 133f4a2713aSLionel Sambuc short y; 134f4a2713aSLionel Sambuc } A1; 135f4a2713aSLionel Sambuc 136f4a2713aSLionel Sambuc // CHECK: Type: struct A1 137f4a2713aSLionel Sambuc // CHECK: Size:96 138f4a2713aSLionel Sambuc // CHECK: Alignment:8 139f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 8, 40, 40, 72, 75, 80]> 140f4a2713aSLionel Sambuc 141f4a2713aSLionel Sambuc typedef struct B1 { 142f4a2713aSLionel Sambuc char x; 143f4a2713aSLionel Sambuc int : 0; 144f4a2713aSLionel Sambuc short a : 4; 145f4a2713aSLionel Sambuc char y; 146f4a2713aSLionel Sambuc } B1; 147f4a2713aSLionel Sambuc 148f4a2713aSLionel Sambuc // CHECK: Type: struct B1 149f4a2713aSLionel Sambuc // CHECK: Size:32 150f4a2713aSLionel Sambuc // CHECK: Alignment:8 151f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 8, 8, 24]> 152f4a2713aSLionel Sambuc 153f4a2713aSLionel Sambuc typedef struct C1 { 154f4a2713aSLionel Sambuc char x; 155f4a2713aSLionel Sambuc short a : 4; 156f4a2713aSLionel Sambuc int : 0; 157f4a2713aSLionel Sambuc char y; 158f4a2713aSLionel Sambuc } C1; 159f4a2713aSLionel Sambuc 160f4a2713aSLionel Sambuc // CHECK: Type: struct C1 161f4a2713aSLionel Sambuc // CHECK: Size:32 162f4a2713aSLionel Sambuc // CHECK: Alignment:8 163f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 8, 24, 24]> 164f4a2713aSLionel Sambuc 165f4a2713aSLionel Sambuc typedef struct D1 { 166f4a2713aSLionel Sambuc char x; 167f4a2713aSLionel Sambuc short : 0; 168f4a2713aSLionel Sambuc int : 0; 169f4a2713aSLionel Sambuc char y; 170f4a2713aSLionel Sambuc } D1; 171f4a2713aSLionel Sambuc 172f4a2713aSLionel Sambuc // CHECK: Type: struct D1 173f4a2713aSLionel Sambuc // CHECK: Size:16 174f4a2713aSLionel Sambuc // CHECK: Alignment:8 175f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 8, 8, 8]> 176f4a2713aSLionel Sambuc 177f4a2713aSLionel Sambuc typedef union E1 { 178f4a2713aSLionel Sambuc char x; 179f4a2713aSLionel Sambuc long long a : 3; 180f4a2713aSLionel Sambuc int b : 3; 181f4a2713aSLionel Sambuc long long : 0; 182f4a2713aSLionel Sambuc short y; 183f4a2713aSLionel Sambuc } E1; 184f4a2713aSLionel Sambuc 185f4a2713aSLionel Sambuc // CHECK: Type: union E1 186f4a2713aSLionel Sambuc // CHECK: Size:64 187f4a2713aSLionel Sambuc // CHECK: Alignment:8 188f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 0, 0, 0, 0]> 189f4a2713aSLionel Sambuc 190f4a2713aSLionel Sambuc typedef struct F1 { 191f4a2713aSLionel Sambuc char x; 192f4a2713aSLionel Sambuc char a : 3; 193f4a2713aSLionel Sambuc char b : 3; 194f4a2713aSLionel Sambuc char c : 3; 195f4a2713aSLionel Sambuc short d : 6; 196f4a2713aSLionel Sambuc short e : 6; 197f4a2713aSLionel Sambuc short f : 6; 198f4a2713aSLionel Sambuc short g : 11; 199f4a2713aSLionel Sambuc short h : 11; 200f4a2713aSLionel Sambuc short i : 11; 201f4a2713aSLionel Sambuc short y; 202f4a2713aSLionel Sambuc } F1; 203f4a2713aSLionel Sambuc 204f4a2713aSLionel Sambuc // CHECK: Type: struct F1 205f4a2713aSLionel Sambuc // CHECK: Size:120 206f4a2713aSLionel Sambuc // CHECK: Alignment:8 207f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 8, 11, 16, 24, 30, 40, 56, 72, 88, 104]> 208f4a2713aSLionel Sambuc 209f4a2713aSLionel Sambuc typedef union G1 { 210f4a2713aSLionel Sambuc char x; 211f4a2713aSLionel Sambuc int a : 3; 212f4a2713aSLionel Sambuc int : 0; 213f4a2713aSLionel Sambuc long long : 0; 214f4a2713aSLionel Sambuc short y; 215f4a2713aSLionel Sambuc } G1; 216f4a2713aSLionel Sambuc 217f4a2713aSLionel Sambuc // CHECK: Type: union G1 218f4a2713aSLionel Sambuc // CHECK: Size:32 219f4a2713aSLionel Sambuc // CHECK: Alignment:8 220f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 0, 0, 0, 0]> 221f4a2713aSLionel Sambuc 222f4a2713aSLionel Sambuc typedef struct H1 { 223f4a2713aSLionel Sambuc unsigned long a : 1; 224f4a2713aSLionel Sambuc unsigned char : 0; 225f4a2713aSLionel Sambuc unsigned long : 0; 226f4a2713aSLionel Sambuc unsigned long c : 1; 227f4a2713aSLionel Sambuc } H1; 228f4a2713aSLionel Sambuc 229f4a2713aSLionel Sambuc // CHECK: Type: struct H1 230f4a2713aSLionel Sambuc // CHECK: Size:64 231f4a2713aSLionel Sambuc // CHECK: Alignment:8 232f4a2713aSLionel Sambuc // CHECK: FieldOffsets: [0, 32, 32, 32]> 233f4a2713aSLionel Sambuc 234*0a6a1f1dSLionel Sambuc typedef struct I1 { 235*0a6a1f1dSLionel Sambuc short : 8; 236*0a6a1f1dSLionel Sambuc __declspec(align(16)) short : 8; 237*0a6a1f1dSLionel Sambuc } I1; 238*0a6a1f1dSLionel Sambuc 239*0a6a1f1dSLionel Sambuc // CHECK: Type: struct I1 240*0a6a1f1dSLionel Sambuc // CHECK: Size:16 241*0a6a1f1dSLionel Sambuc // CHECK: Alignment:8 242*0a6a1f1dSLionel Sambuc // CHECK: FieldOffsets: [0, 8] 243*0a6a1f1dSLionel Sambuc 244f4a2713aSLionel Sambuc #pragma pack(pop) 245f4a2713aSLionel Sambuc 246f4a2713aSLionel Sambuc int x[ 247f4a2713aSLionel Sambuc sizeof(A ) + 248f4a2713aSLionel Sambuc sizeof(B ) + 249f4a2713aSLionel Sambuc sizeof(C ) + 250f4a2713aSLionel Sambuc sizeof(D ) + 251f4a2713aSLionel Sambuc sizeof(E ) + 252f4a2713aSLionel Sambuc sizeof(F ) + 253f4a2713aSLionel Sambuc sizeof(G ) + 254f4a2713aSLionel Sambuc sizeof(H ) + 255*0a6a1f1dSLionel Sambuc sizeof(I ) + 256f4a2713aSLionel Sambuc sizeof(A1) + 257f4a2713aSLionel Sambuc sizeof(B1) + 258f4a2713aSLionel Sambuc sizeof(C1) + 259f4a2713aSLionel Sambuc sizeof(D1) + 260f4a2713aSLionel Sambuc sizeof(E1) + 261f4a2713aSLionel Sambuc sizeof(F1) + 262f4a2713aSLionel Sambuc sizeof(G1) + 263f4a2713aSLionel Sambuc sizeof(H1) + 264*0a6a1f1dSLionel Sambuc sizeof(I1) + 265f4a2713aSLionel Sambuc 0]; 266