2014-02-28 04:30:49 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -Wno-error=incompatible-ms-struct -verify -triple i686-apple-darwin9 -std=c++11 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -Wno-error=incompatible-ms-struct -verify -triple armv7-apple-darwin9 -std=c++11 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_ERROR -verify -triple armv7-apple-darwin9 -std=c++11 %s
|
2013-06-27 04:50:34 +08:00
|
|
|
|
|
|
|
#pragma ms_struct on
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
unsigned long a:4;
|
|
|
|
unsigned char b;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B : public A {
|
2014-02-28 04:30:49 +08:00
|
|
|
#ifdef TEST_FOR_ERROR
|
2015-07-29 00:48:12 +08:00
|
|
|
// expected-error@-2 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}}
|
2014-02-28 04:30:49 +08:00
|
|
|
#else
|
2015-07-29 00:48:12 +08:00
|
|
|
// expected-warning@-4 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}}
|
2014-02-28 04:30:49 +08:00
|
|
|
#endif
|
2013-06-27 04:50:34 +08:00
|
|
|
unsigned long c:16;
|
|
|
|
int d;
|
|
|
|
B();
|
|
|
|
};
|
|
|
|
|
|
|
|
static_assert(__builtin_offsetof(B, d) == 12,
|
2014-02-28 04:30:49 +08:00
|
|
|
"We can't allocate the bitfield into the padding under ms_struct");
|
|
|
|
|
|
|
|
// rdar://16178895
|
|
|
|
struct C {
|
|
|
|
#ifdef TEST_FOR_ERROR
|
2015-07-29 00:48:12 +08:00
|
|
|
// expected-error@-2 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}}
|
2014-02-28 04:30:49 +08:00
|
|
|
#else
|
2015-07-29 00:48:12 +08:00
|
|
|
// expected-warning@-4 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}}
|
2014-02-28 04:30:49 +08:00
|
|
|
#endif
|
|
|
|
virtual void foo();
|
|
|
|
long long n;
|
|
|
|
};
|
|
|
|
|
|
|
|
static_assert(__builtin_offsetof(C, n) == 8,
|
|
|
|
"long long field in ms_struct should be 8-byte aligned");
|