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