test constant folding with bitset values
authorMatthias Braun <matze@braunis.de>
Fri, 9 Feb 2007 13:55:20 +0000 (13:55 +0000)
committerMatthias Braun <matze@braunis.de>
Fri, 9 Feb 2007 13:55:20 +0000 (13:55 +0000)
ir/be/test/bf_constfold.c [new file with mode: 0644]

diff --git a/ir/be/test/bf_constfold.c b/ir/be/test/bf_constfold.c
new file mode 100644 (file)
index 0000000..28036c1
--- /dev/null
@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+/* Demonstrates a bug where constant folding ignores width of bitfields */
+
+struct __attribute__((packed)) A
+{
+       unsigned int i:1, l:1, j:3, k:11;
+};
+struct A sA;
+
+int main()
+{
+       unsigned int mask;
+       struct A x;
+
+       sA.k = -1;
+       mask = sA.k;
+       x = sA;
+
+       printf("Val1: %x (expected 7ff) val2: %x (expected 7ff)\n", mask, x.k);
+
+       return 0;
+}