33 lines · c
1// RUN: %clang_cc1 -mms-bitfields -fsyntax-only -verify -triple x86_64-apple-darwin9 %s2// RUN: %clang_cc1 -mms-bitfields -fsyntax-only -Wms-bitfield-padding -verify=checkms -triple x86_64-apple-darwin9 %s3 4// expected-no-diagnostics5 6// The -mms-bitfields commandline parameter should behave the same7// as the ms_struct attribute.8struct9{10 int a : 1; // #a11 short b : 1;12 // 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}}13 // checkms-note@#a {{preceding bit-field 'a' declared here with type 'int'}}14} t;15 16// MS pads out bitfields between different types.17static int arr[(sizeof(t) == 8) ? 1 : -1];18 19#pragma pack (push,1)20 21typedef unsigned int UINT32;22 23struct Inner {24 UINT32 A : 1;25 UINT32 B : 1;26 UINT32 C : 1;27 UINT32 D : 30;28} Inner;29 30#pragma pack (pop)31 32static int arr2[(sizeof(Inner) == 8) ? 1 : -1];33