summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/arm-apcs-zerolength-bitfield.c
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2011-08-04 01:21:14 +0000
committerChad Rosier <mcrosier@apple.com>2011-08-04 01:21:14 +0000
commit18903ee2d383a93d079a801258bf25d46ba1f995 (patch)
tree983435286ec5ba090595c468993835003a088587 /clang/test/CodeGen/arm-apcs-zerolength-bitfield.c
parentbc673fb5f2fb6f1a8b148f9bc4bf3cabd2ff8184 (diff)
downloadbcm5719-llvm-18903ee2d383a93d079a801258bf25d46ba1f995.tar.gz
bcm5719-llvm-18903ee2d383a93d079a801258bf25d46ba1f995.zip
Add partial support for using anonymous bitfields (e.g., int : 0) to enforce
alignment. This fixes cases where the anonymous bitfield is followed by a non-bitfield member. E.g., struct t4 { int foo : 1; long : 0; char bar; }; Part of rdar://9859156 llvm-svn: 136858
Diffstat (limited to 'clang/test/CodeGen/arm-apcs-zerolength-bitfield.c')
-rw-r--r--clang/test/CodeGen/arm-apcs-zerolength-bitfield.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/clang/test/CodeGen/arm-apcs-zerolength-bitfield.c b/clang/test/CodeGen/arm-apcs-zerolength-bitfield.c
index 0b26d382e22..4b16e0c832b 100644
--- a/clang/test/CodeGen/arm-apcs-zerolength-bitfield.c
+++ b/clang/test/CodeGen/arm-apcs-zerolength-bitfield.c
@@ -1,4 +1,8 @@
// RUN: %clang_cc1 -target-abi apcs-gnu -triple armv7-apple-darwin10 %s -verify
+//
+// Note: gcc forces the alignment to 4 bytes, regardless of the type of the
+// zero length bitfield.
+// rdar://9859156
#include <stddef.h>
@@ -8,8 +12,8 @@ struct t1
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];
+static int arr1_offset[(offsetof(struct t1, bar) == 4) ? 0 : -1];
+static int arr1_sizeof[(sizeof(struct t1) == 8) ? 0 : -1];
struct t2
{
@@ -17,8 +21,8 @@ struct t2
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];
+static int arr2_offset[(offsetof(struct t2, bar) == 4) ? 0 : -1];
+static int arr2_sizeof[(sizeof(struct t2) == 8) ? 0 : -1];
struct t3
{
@@ -26,8 +30,8 @@ struct t3
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];
+static int arr3_offset[(offsetof(struct t3, bar) == 4) ? 0 : -1];
+static int arr3_sizeof[(sizeof(struct t3) == 8) ? 0 : -1];
struct t4
{
@@ -35,8 +39,8 @@ struct t4
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];
+static int arr4_offset[(offsetof(struct t4, bar) == 4) ? 0 : -1];
+static int arr4_sizeof[(sizeof(struct t4) == 8) ? 0 : -1];
struct t5
{
@@ -44,8 +48,8 @@ struct t5
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];
+static int arr5_offset[(offsetof(struct t5, bar) == 4) ? 0 : -1];
+static int arr5_sizeof[(sizeof(struct t5) == 8) ? 0 : -1];
struct t6
{
@@ -109,6 +113,17 @@ struct t11
static int arr11_offset[(offsetof(struct t11, bar2) == 1) ? 0 : -1];
static int arr11_sizeof[(sizeof(struct t11) == 2) ? 0 : -1];
+struct t12
+{
+ int foo : 1;
+ char : 0;
+ long long : 0;
+ char : 0;
+ char bar;
+};
+static int arr12_offset[(offsetof(struct t12, bar) == 4) ? 0 : -1];
+static int arr12_sizeof[(sizeof(struct t12) == 8) ? 0 : -1];
+
int main() {
return 0;
}
OpenPOWER on IntegriCloud