Rewrite record layout for ms_struct structs.
The old implementation of ms_struct in RecordLayoutBuilder was a
complete mess: it depended on complicated conditionals which didn't
really reflect the underlying logic, and placed a burden on users of
the resulting RecordLayout. This commit rips out almost all of the
old code, and replaces it with simple checks in
RecordLayoutBuilder::LayoutBitField.
This commit also fixes <rdar://problem/14252115>, a bug where class
inheritance would cause us to lay out bitfields incorrectly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185018 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/ms_struct.cpp b/test/SemaCXX/ms_struct.cpp
new file mode 100644
index 0000000..fd1ed90
--- /dev/null
+++ b/test/SemaCXX/ms_struct.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-darwin9 -std=c++11 %s
+// expected-no-diagnostics
+
+#pragma ms_struct on
+
+struct A {
+ unsigned long a:4;
+ unsigned char b;
+ A();
+};
+
+struct B : public A {
+ unsigned long c:16;
+ int d;
+ B();
+};
+
+static_assert(__builtin_offsetof(B, d) == 12,
+ "We can't allocate the bitfield into the padding under ms_struct");
\ No newline at end of file