]> granicus.if.org Git - clang/commitdiff
Add test case for PR2001.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 5 Aug 2008 16:15:29 +0000 (16:15 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 5 Aug 2008 16:15:29 +0000 (16:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54352 91177308-0d34-0410-b5e6-96231b3b80d8

test/CodeGen/PR2001-bitfield-reload.c [new file with mode: 0644]

diff --git a/test/CodeGen/PR2001-bitfield-reload.c b/test/CodeGen/PR2001-bitfield-reload.c
new file mode 100644 (file)
index 0000000..caafced
--- /dev/null
@@ -0,0 +1,17 @@
+// RUN: clang --emit-llvm-bc -o - %s | opt --std-compile-opts | llvm-dis > %t &&
+// RUN: grep "ret i32" %t | count 1 &&
+// RUN: grep "ret i32 1" %t | count 1
+// PR2001
+
+/* Test that the result of the assignment properly uses the value *in
+   the bitfield* as opposed to the RHS. */
+static int foo(int i) {
+  struct {
+    int f0 : 2;
+  } x;
+  return (x.f0 = i);
+}
+
+int bar() {
+  return foo(-5) == -1;
+}