summaryrefslogtreecommitdiff
path: root/test/regression
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-12-18 07:55:07 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2012-12-18 07:55:07 +0000
commit8ed2c113bbc9c43d0993d4e92878eb987c7f3a1c (patch)
tree5cd95119f6f63d1f7c16579199cfe60909dc989e /test/regression
parent712f3cbae6bfd3c6f6cc40d44f438aa0affcd371 (diff)
Test bitfields of enum type
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2075 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/regression')
-rw-r--r--test/regression/Results/bitfields84
-rw-r--r--test/regression/bitfields8.c24
2 files changed, 28 insertions, 0 deletions
diff --git a/test/regression/Results/bitfields8 b/test/regression/Results/bitfields8
new file mode 100644
index 0000000..81dd9d4
--- /dev/null
+++ b/test/regression/Results/bitfields8
@@ -0,0 +1,4 @@
+s.x = 0, s.y = -2
+s.x = 1, s.y = -1
+s.x = 2, s.y = 0
+s.x = 3, s.y = 1
diff --git a/test/regression/bitfields8.c b/test/regression/bitfields8.c
new file mode 100644
index 0000000..8bc0c27
--- /dev/null
+++ b/test/regression/bitfields8.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+/* Best-choice for signedness of bit-fields of enum type */
+
+enum E1 { A = 0, B, C, D };
+enum E2 { E = -2, F, G, H };
+
+struct S { enum E1 x : 2; enum E2 y : 2; };
+
+struct S s;
+
+void printS(void)
+{
+ printf("s.x = %d, s.y = %d\n", s.x, s.y);
+}
+
+int main(void)
+{
+ s.x = A; s.y = E; printS();
+ s.x = B; s.y = F; printS();
+ s.x = C; s.y = G; printS();
+ s.x = D; s.y = H; printS();
+ return 0;
+}