summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2008-05-17 20:03:47 +0000
committerEli Friedman <eli.friedman@gmail.com>2008-05-17 20:03:47 +0000
commitf2442dcc8d653d3dcb37104df35357d2ed31a31a (patch)
treea6d786f30735ee3799676e63881ef908dbd649f4 /clang/test
parenteb185ca5e95aad1e3f61971bf1e39b1035b409d1 (diff)
downloadbcm5719-llvm-f2442dcc8d653d3dcb37104df35357d2ed31a31a.tar.gz
bcm5719-llvm-f2442dcc8d653d3dcb37104df35357d2ed31a31a.zip
Fix support for _Bool bitfields. The issue is that the bitfield width
used for _Bool is not the same as the primitive width (which for _Bool is 1 bit). The load and store changes add some casts to make the types consistent. The EmitLValue changes make sure that the pointer is of an appropriate type for loading the bitfield. This isn't perfect, but it's an improvement, and getting everything right depends on actually laying out structs in an ABI-compliant way. llvm-svn: 51224
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CodeGen/bool-bitfield.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/clang/test/CodeGen/bool-bitfield.c b/clang/test/CodeGen/bool-bitfield.c
new file mode 100644
index 00000000000..09298ed53b9
--- /dev/null
+++ b/clang/test/CodeGen/bool-bitfield.c
@@ -0,0 +1,54 @@
+// RUN: clang -emit-llvm %s
+
+// From GCC PR19331
+struct SysParams
+{
+ unsigned short tag;
+ unsigned short version;
+ unsigned int seqnum;
+ int contrast;
+ int igain_1, igain_2;
+ int oattn_1, oattn_2;
+ int max_out_vltg_1, max_out_vltg_2;
+ int max_mains_current;
+ int meters_mode;
+ int input_select;
+ _Bool input_parallelch2:1;
+ _Bool cliplmt_ch1:1;
+ _Bool cliplmt_ch2:1;
+ _Bool gate_ch1:1;
+ _Bool gate_ch2:1;
+ _Bool mute_ch1:1;
+ _Bool mute_ch2:1;
+ _Bool brownout:1;
+ _Bool power_on:1;
+ _Bool pwrup_mute:1;
+ _Bool keylock:1;
+ _Bool dsp_ch1:1;
+ _Bool dsp_ch2:1;
+ int dsp_preset;
+ long unlock_code;
+};
+extern struct SysParams params;
+
+void foo(void *);
+void kcmd_setParams(void)
+{
+ struct {
+ unsigned char igain_1;
+ unsigned char igain_2;
+ unsigned char max_out_vltg_1;
+ unsigned char max_out_vltg_2;
+ unsigned char max_imains;
+ unsigned char cliplmt_ch1:1;
+ unsigned char cliplmt_ch2:1;
+ unsigned char gate_ch1:1;
+ unsigned char gate_ch2:1;
+ } msg;
+ foo(&msg);
+ params.cliplmt_ch1 = msg.cliplmt_ch1;
+ params.cliplmt_ch2 = msg.cliplmt_ch2;
+ params.gate_ch1 = msg.gate_ch1;
+ params.gate_ch2 = msg.gate_ch2;
+}
+
OpenPOWER on IntegriCloud