diff options
author | John McCall <rjmccall@apple.com> | 2014-02-13 00:50:08 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2014-02-13 00:50:08 +0000 |
commit | 76e1818a2b1248579557de2927c135c322577c82 (patch) | |
tree | 97f810d731fee38edf168e563493a8ad48000ed5 /clang/test/CodeGen/ms_struct-bitfield.c | |
parent | 5d4d61f64f1c282333b2810e57ffc2ca1ef84e51 (diff) | |
download | bcm5719-llvm-76e1818a2b1248579557de2927c135c322577c82.tar.gz bcm5719-llvm-76e1818a2b1248579557de2927c135c322577c82.zip |
ms_struct layout replaces platform-specific behavior like
useBitFieldTypeAlignment() and appears to ignore the special
bit-packing semantics of __attribute__((packed)).
Further flesh out an already-extensive comment.
llvm-svn: 201282
Diffstat (limited to 'clang/test/CodeGen/ms_struct-bitfield.c')
-rw-r--r-- | clang/test/CodeGen/ms_struct-bitfield.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/clang/test/CodeGen/ms_struct-bitfield.c b/clang/test/CodeGen/ms_struct-bitfield.c index 451113c123e..08f2a5b60a5 100644 --- a/clang/test/CodeGen/ms_struct-bitfield.c +++ b/clang/test/CodeGen/ms_struct-bitfield.c @@ -1,7 +1,11 @@ // RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-apple-darwin9 %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -triple thumbv7-apple-ios -target-abi apcs-gnu %s | FileCheck %s -check-prefix=CHECK-ARM // rdar://8823265 +// Note that we're declaring global variables with these types, +// triggering both Sema and IRGen struct layout. + #define ATTR __attribute__((__ms_struct__)) struct @@ -12,6 +16,7 @@ struct } ATTR t1; int s1 = sizeof(t1); // CHECK: @s1 = global i32 2 +// CHECK-ARM: @s1 = global i32 2 struct { @@ -23,6 +28,7 @@ struct } ATTR t2; int s2 = sizeof(t2); // CHECK: @s2 = global i32 2 +// CHECK-ARM: @s2 = global i32 2 struct { @@ -36,6 +42,7 @@ struct } ATTR t3; int s3 = sizeof(t3); // CHECK: @s3 = global i32 2 +// CHECK-ARM: @s3 = global i32 2 struct { @@ -44,6 +51,7 @@ struct } ATTR t4; int s4 = sizeof(t4); // CHECK: @s4 = global i32 1 +// CHECK-ARM: @s4 = global i32 1 struct { @@ -54,6 +62,7 @@ struct } ATTR t5; int s5 = sizeof(t5); // CHECK: @s5 = global i32 1 +// CHECK-ARM: @s5 = global i32 1 struct { @@ -64,6 +73,7 @@ struct } ATTR t6; int s6 = sizeof(t6); // CHECK: @s6 = global i32 1 +// CHECK-ARM: @s6 = global i32 1 struct { @@ -84,6 +94,7 @@ struct } ATTR t7; int s7 = sizeof(t7); // CHECK: @s7 = global i32 9 +// CHECK-ARM: @s7 = global i32 9 struct { @@ -93,6 +104,7 @@ struct } ATTR t8; int s8 = sizeof(t8); // CHECK: @s8 = global i32 0 +// CHECK-ARM: @s8 = global i32 0 struct { @@ -125,6 +137,7 @@ struct } ATTR t9; int s9 = sizeof(t9); // CHECK: @s9 = global i32 28 +// CHECK-ARM: @s9 = global i32 28 struct { @@ -134,3 +147,33 @@ struct } ATTR t10; int s10 = sizeof(t10); // CHECK: @s10 = global i32 16 +// CHECK-ARM: @s10 = global i32 8 + +// rdar://16041826 - ensure that ms_structs work correctly on a +// !useBitFieldTypeAlignment() target +struct { + unsigned int a : 31; + unsigned int b : 2; + unsigned int c; +} ATTR t11; +int s11 = sizeof(t11); +// CHECK: @s11 = global i32 12 +// CHECK-ARM: @s11 = global i32 12 + +struct { + unsigned char a : 3; + unsigned char b : 4; + unsigned short c : 6; +} ATTR t12; +int s12 = sizeof(t12); +// CHECK: @s12 = global i32 4 +// CHECK-ARM: @s12 = global i32 4 + +struct { + unsigned char a : 3; + unsigned char b : 4; + __attribute__((packed)) unsigned short c : 6; +} ATTR t13; +int s13 = sizeof(t13); +// CHECK: @s13 = global i32 4 +// CHECK-ARM: @s13 = global i32 4 |