diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2013-06-26 20:50:34 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2013-06-26 20:50:34 +0000 |
commit | 2782dacfbcb48a1430b9114d801ba90fc2babd69 (patch) | |
tree | 6da85c0fc9a21651ecac6f71a7979db64fdabfc6 /clang/test/SemaCXX | |
parent | 6db14a996563072f07a7da85b42a56bf72e6133d (diff) | |
download | bcm5719-llvm-2782dacfbcb48a1430b9114d801ba90fc2babd69.tar.gz bcm5719-llvm-2782dacfbcb48a1430b9114d801ba90fc2babd69.zip |
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.
llvm-svn: 185018
Diffstat (limited to 'clang/test/SemaCXX')
-rw-r--r-- | clang/test/SemaCXX/ms_struct.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/ms_struct.cpp b/clang/test/SemaCXX/ms_struct.cpp new file mode 100644 index 00000000000..fd1ed904fa8 --- /dev/null +++ b/clang/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 |