summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/arm-apcs-zerolength-bitfield.c
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2011-08-04 00:19:13 +0000
committerChad Rosier <mcrosier@apple.com>2011-08-04 00:19:13 +0000
commit6088393248499dd4406fde5bb336c95f2d9cf778 (patch)
treea79a8d755807eaac7905799e3b048037af20221a /clang/test/CodeGen/arm-apcs-zerolength-bitfield.c
parentc27b2870d88aceabe4a4c553a4181fbf3e97aee8 (diff)
downloadbcm5719-llvm-6088393248499dd4406fde5bb336c95f2d9cf778.tar.gz
bcm5719-llvm-6088393248499dd4406fde5bb336c95f2d9cf778.zip
For APCS the alignment of bitfield types is *not* respected when laying out
structures. Alignment can be enforced with the use of anonymous bitfields (e.g., int :0), but this is not currently supported. Add this test case to document the current state, which will hopefully be fixed shortly. llvm-svn: 136848
Diffstat (limited to 'clang/test/CodeGen/arm-apcs-zerolength-bitfield.c')
-rw-r--r--clang/test/CodeGen/arm-apcs-zerolength-bitfield.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/clang/test/CodeGen/arm-apcs-zerolength-bitfield.c b/clang/test/CodeGen/arm-apcs-zerolength-bitfield.c
new file mode 100644
index 00000000000..0b26d382e22
--- /dev/null
+++ b/clang/test/CodeGen/arm-apcs-zerolength-bitfield.c
@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 -target-abi apcs-gnu -triple armv7-apple-darwin10 %s -verify
+
+#include <stddef.h>
+
+struct t1
+{
+ int foo : 1;
+ char : 0;
+ char bar;
+};
+static int arr1_offset[(offsetof(struct t1, bar) == 1) ? 0 : -1];
+static int arr1_sizeof[(sizeof(struct t1) == 2) ? 0 : -1];
+
+struct t2
+{
+ int foo : 1;
+ short : 0;
+ char bar;
+};
+static int arr2_offset[(offsetof(struct t2, bar) == 1) ? 0 : -1];
+static int arr2_sizeof[(sizeof(struct t2) == 2) ? 0 : -1];
+
+struct t3
+{
+ int foo : 1;
+ int : 0;
+ char bar;
+};
+static int arr3_offset[(offsetof(struct t3, bar) == 1) ? 0 : -1];
+static int arr3_sizeof[(sizeof(struct t3) == 2) ? 0 : -1];
+
+struct t4
+{
+ int foo : 1;
+ long : 0;
+ char bar;
+};
+static int arr4_offset[(offsetof(struct t4, bar) == 1) ? 0 : -1];
+static int arr4_sizeof[(sizeof(struct t4) == 2) ? 0 : -1];
+
+struct t5
+{
+ int foo : 1;
+ long long : 0;
+ char bar;
+};
+static int arr5_offset[(offsetof(struct t5, bar) == 1) ? 0 : -1];
+static int arr5_sizeof[(sizeof(struct t5) == 2) ? 0 : -1];
+
+struct t6
+{
+ int foo : 1;
+ char : 0;
+ char bar : 1;
+ char bar2;
+};
+static int arr6_offset[(offsetof(struct t6, bar2) == 1) ? 0 : -1];
+static int arr6_sizeof[(sizeof(struct t6) == 2) ? 0 : -1];
+
+struct t7
+{
+ int foo : 1;
+ short : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr7_offset[(offsetof(struct t7, bar2) == 1) ? 0 : -1];
+static int arr7_sizeof[(sizeof(struct t7) == 2) ? 0 : -1];
+
+struct t8
+{
+ int foo : 1;
+ int : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr8_offset[(offsetof(struct t8, bar2) == 1) ? 0 : -1];
+static int arr8_sizeof[(sizeof(struct t8) == 2) ? 0 : -1];
+
+struct t9
+{
+ int foo : 1;
+ long : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr9_offset[(offsetof(struct t9, bar2) == 1) ? 0 : -1];
+static int arr9_sizeof[(sizeof(struct t9) == 2) ? 0 : -1];
+
+struct t10
+{
+ int foo : 1;
+ long long : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr10_offset[(offsetof(struct t10, bar2) == 1) ? 0 : -1];
+static int arr10_sizeof[(sizeof(struct t10) == 2) ? 0 : -1];
+
+
+struct t11
+{
+ int foo : 1;
+ long long : 0;
+ char : 0;
+ char bar1 : 1;
+ char bar2;
+};
+static int arr11_offset[(offsetof(struct t11, bar2) == 1) ? 0 : -1];
+static int arr11_sizeof[(sizeof(struct t11) == 2) ? 0 : -1];
+
+int main() {
+ return 0;
+}
+
OpenPOWER on IntegriCloud