aboutsummaryrefslogtreecommitdiffstats
path: root/test/regression/sizeof1.c
diff options
context:
space:
mode:
authorxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-03-03 10:22:27 +0000
committerxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-03-03 10:22:27 +0000
commit891377ce1962cdb31357d6580d6546ec22df2b4f (patch)
tree4ff7c38749cc7a4c1af411c5aa3eb7225c4ae6a1 /test/regression/sizeof1.c
parent018edf2d81bf94197892cf1df221f7eeac1f96f6 (diff)
downloadcompcert-kvx-891377ce1962cdb31357d6580d6546ec22df2b4f.tar.gz
compcert-kvx-891377ce1962cdb31357d6580d6546ec22df2b4f.zip
Switching to the new C parser/elaborator/simplifier
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1269 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/regression/sizeof1.c')
-rw-r--r--test/regression/sizeof1.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/regression/sizeof1.c b/test/regression/sizeof1.c
new file mode 100644
index 00000000..e8441a2c
--- /dev/null
+++ b/test/regression/sizeof1.c
@@ -0,0 +1,31 @@
+struct s {
+ char c;
+ union { int i[3]; double d; } n;
+ struct { struct s * hd; struct s * tl; } l;
+};
+
+char tbl[sizeof(struct s)];
+/* Should be 32:
+ char c at 0
+ union n at 8 because alignment = 8; sizeof = 12
+ struct l at 8+12=20 with alignment = 4; sizeof = 8
+ end of struct at 20+8=28
+ alignment of whole struct is 8 because of d
+ 28 aligned to 8 -> 32
+*/
+
+struct bits1 {
+ unsigned a: 1;
+ unsigned b: 6;
+};
+
+char b1[sizeof(struct bits1)]; /* should be 1 */
+
+struct bits2 {
+ unsigned a: 1;
+ unsigned b: 6;
+ unsigned c: 28;
+};
+
+char b2[sizeof(struct bits2)]; /* should be 8 */
+