tricky bitfield test from gcc (extended)
authorMatthias Braun <matze@braunis.de>
Fri, 3 Oct 2008 17:16:10 +0000 (17:16 +0000)
committerMatthias Braun <matze@braunis.de>
Fri, 3 Oct 2008 17:16:10 +0000 (17:16 +0000)
[r22435]

parsetest/bitfield2.c [new file with mode: 0644]

diff --git a/parsetest/bitfield2.c b/parsetest/bitfield2.c
new file mode 100644 (file)
index 0000000..03dd1ec
--- /dev/null
@@ -0,0 +1,23 @@
+struct x {
+  unsigned x1:1;
+  unsigned x2:2;
+  unsigned x3:3;
+  unsigned x4:4;
+};
+
+void foobar (int x, int y, int z)
+{
+  struct x a = {x, y, z, 7};
+  struct x b = {x, y, z, 3};
+  struct x *c = &b;
+
+  c->x3 += (a.x2 - a.x1) * c->x2;
+  if (a.x1 != 1 || c->x3 != 5)
+    abort ();
+  exit (0);
+}
+
+int main()
+{
+  foobar (1, 2, 3);
+}