summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/bitfield-promote-int-16bit.c
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-08-20 04:21:42 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-08-20 04:21:42 +0000
commit629ffb9ad310dc1cfadddc98d94fe1746d289354 (patch)
tree56877eae484abc5dac0459515293d38dae3ef6b3 /clang/test/Sema/bitfield-promote-int-16bit.c
parent1a3ec57520df7fbd51c62ad931fbdb85025fb49c (diff)
downloadbcm5719-llvm-629ffb9ad310dc1cfadddc98d94fe1746d289354.tar.gz
bcm5719-llvm-629ffb9ad310dc1cfadddc98d94fe1746d289354.zip
Fix bit-field promotion to be a bit closer to the behavior of gcc.
Patch by Enea Zaffanella, with some simplifications/corrections to isPromotableBitField by me. llvm-svn: 79510
Diffstat (limited to 'clang/test/Sema/bitfield-promote-int-16bit.c')
-rw-r--r--clang/test/Sema/bitfield-promote-int-16bit.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/test/Sema/bitfield-promote-int-16bit.c b/clang/test/Sema/bitfield-promote-int-16bit.c
new file mode 100644
index 00000000000..12d47205e87
--- /dev/null
+++ b/clang/test/Sema/bitfield-promote-int-16bit.c
@@ -0,0 +1,25 @@
+// RUN: clang-cc -fsyntax-only -verify %s -triple pic16-unknown-unknown
+
+// Check that int-sized unsigned bit-fields promote to unsigned int
+// on targets where sizeof(unsigned short) == sizeof(unsigned int)
+
+enum E { ec1, ec2, ec3 };
+struct S {
+ enum E e : 16;
+ unsigned short us : 16;
+ unsigned long ul1 : 8;
+ unsigned long ul2 : 16;
+} s;
+
+__typeof(s.e + s.e) x_e;
+unsigned x_e;
+
+__typeof(s.us + s.us) x_us;
+unsigned x_us;
+
+__typeof(s.ul1 + s.ul1) x_ul1;
+signed x_ul1;
+
+__typeof(s.ul2 + s.ul2) x_ul2;
+unsigned x_ul2;
+
OpenPOWER on IntegriCloud