| 1 |
// RUN: %clang_cc1 -fms-layout-compatibility=microsoft -fsyntax-only -verify -triple x86_64-apple-darwin9 %s |
| 2 |
// RUN: %clang_cc1 -fms-layout-compatibility=microsoft -fsyntax-only -Wms-bitfield-padding -verify=checkms -triple x86_64-apple-darwin9 %s |
| 3 |
// expected-no-diagnostics |
| 4 |
|
| 5 |
// The -mms-bitfields commandline parameter should behave the same |
| 6 |
// as the ms_struct attribute. |
| 7 |
struct |
| 8 |
{ |
| 9 |
int a : 1; // #a |
| 10 |
short b : 1; |
| 11 |
// checkms-warning@-1 {{bit-field 'b' of type 'short' has a different storage size than the preceding bit-field (2 vs 4 bytes) and will not be packed under the Microsoft ABI}} |
| 12 |
// checkms-note@#a {{preceding bit-field 'a' declared here with type 'int'}} |
| 13 |
} t; |
| 14 |
|
| 15 |
// MS pads out bitfields between different types. |
| 16 |
static int arr[(sizeof(t) == 8) ? 1 : -1]; |
| 17 |
|
| 18 |
#pragma pack (push,1) |
| 19 |
|
| 20 |
typedef unsigned int UINT32; |
| 21 |
|
| 22 |
struct Inner { |
| 23 |
UINT32 A : 1; |
| 24 |
UINT32 B : 1; |
| 25 |
UINT32 C : 1; |
| 26 |
UINT32 D : 30; |
| 27 |
} Inner; |
| 28 |
|
| 29 |
#pragma pack (pop) |
| 30 |
|
| 31 |
static int arr2[(sizeof(Inner) == 8) ? 1 : -1]; |