summaryrefslogtreecommitdiff
path: root/bindgen-integration/cpp/Test.h
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-06-04 01:22:07 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-06-05 20:05:01 +0200
commit10106aa8a40f36477fdc9cd034d9a2eec2698318 (patch)
tree043ca73acc6457521eca880e2379ed711c783f04 /bindgen-integration/cpp/Test.h
parent1f87fc87bc0ffb90e1ff22e19e31b53bfdae64b9 (diff)
ir: Fix a bunch of bitfield correctness issues.
In particular, the "flush the allocation unit" logic is only valid for ms_structs (that is, MSVC). It's slightly annoying to have this different behavior, but it'd work just fine if we'd turn that on for MSVC. This patch doesn't do that, yet at least, and adds tests for all the weird bitfield alignments around. Fixes #726 (and another set of hidden issues by the old code).
Diffstat (limited to 'bindgen-integration/cpp/Test.h')
-rw-r--r--bindgen-integration/cpp/Test.h31
1 files changed, 30 insertions, 1 deletions
diff --git a/bindgen-integration/cpp/Test.h b/bindgen-integration/cpp/Test.h
index 01c7aea1..4b8c1690 100644
--- a/bindgen-integration/cpp/Test.h
+++ b/bindgen-integration/cpp/Test.h
@@ -49,7 +49,7 @@ struct Second {
};
enum ItemKind {
- ITEM_KIND_UNO,
+ ITEM_KIND_UNO = 0,
ITEM_KIND_DOS,
ITEM_KIND_TRES,
};
@@ -63,6 +63,35 @@ struct Third {
bool assert(int first, bool second, ItemKind third);
};
+enum MyEnum {
+ ONE = 0,
+ TWO,
+ THREE,
+ FOUR,
+};
+
+struct Fourth {
+ MyEnum tag: 2;
+ unsigned long ptr: 48;
+
+ /// Returns true if the bitfields match the arguments, false otherwise.
+ bool assert(MyEnum tag, unsigned long ptr);
+};
+
+struct Date2 {
+ unsigned short nWeekDay : 3; // 0..7 (3 bits)
+ unsigned short nMonthDay : 6; // 0..31 (6 bits)
+ unsigned short nMonth : 5; // 0..12 (5 bits)
+ unsigned short nYear : 8; // 0..100 (8 bits)
+ unsigned char byte : 8;
+
+ bool assert(unsigned short nWeekDay,
+ unsigned short nMonthDay,
+ unsigned short nMonth,
+ unsigned short nYear,
+ unsigned short byte);
+};
+
} // namespace bitfields
struct AutoRestoreBool {