1 // RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_WARNING -Wno-error=incompatible-ms-struct -verify -triple i686-apple-darwin9 -std=c++11 %s 2 // RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_WARNING -Wno-error=incompatible-ms-struct -verify -triple armv7-apple-darwin9 -std=c++11 %s 3 // RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_ERROR -verify -triple armv7-apple-darwin9 -std=c++11 %s 4 // RUN: %clang_cc1 -fsyntax-only -DNO_PRAGMA -mms-bitfields -verify -triple armv7-apple-darwin9 -std=c++11 %s 5 6 #ifndef NO_PRAGMA 7 #pragma ms_struct on 8 #endif 9 10 struct A { 11 unsigned long a:4; 12 unsigned char b; 13 }; 14 15 struct B : public A { 16 #ifdef TEST_FOR_ERROR 17 // expected-error@-2 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}} 18 #elif defined(TEST_FOR_WARNING) 19 // expected-warning@-4 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}} 20 #endif 21 unsigned long c:16; 22 int d; 23 B(); 24 }; 25 26 static_assert(__builtin_offsetof(B, d) == 12, 27 "We can't allocate the bitfield into the padding under ms_struct"); 28 29 // rdar://16178895 30 struct C { 31 #ifdef TEST_FOR_ERROR 32 // expected-error@-2 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}} 33 #elif defined(TEST_FOR_WARNING) 34 // expected-warning@-4 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}} 35 #endif 36 virtual void foo(); 37 long long n; 38 }; 39 40 static_assert(__builtin_offsetof(C, n) == 8, 41 "long long field in ms_struct should be 8-byte aligned"); 42 #if !defined(TEST_FOR_ERROR) && !defined(TEST_FOR_WARNING) 43 // expected-no-diagnostics 44 #endif 45