[llvm-commits] CVS: llvm/test/C++Frontend/2007-05-15-FieldAccess.cpp
Reid Spencer
reid at x10sys.com
Mon May 14 23:52:34 PDT 2007
Changes in directory llvm/test/C++Frontend:
2007-05-15-FieldAccess.cpp added (r1.1)
---
Log message:
Add a test case for PR1420: http://llvm.org/PR1420
---
Diffs of the changes: (+35 -0)
2007-05-15-FieldAccess.cpp | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+)
Index: llvm/test/C++Frontend/2007-05-15-FieldAccess.cpp
diff -c /dev/null llvm/test/C++Frontend/2007-05-15-FieldAccess.cpp:1.1
*** /dev/null Tue May 15 01:52:25 2007
--- llvm/test/C++Frontend/2007-05-15-FieldAccess.cpp Tue May 15 01:52:15 2007
***************
*** 0 ****
--- 1,35 ----
+ // Test case for PR1420
+ // RUN: %llvmgxx %s -O0 -o %t.exe
+ // RUN: %t.exe > %t.out
+ // RUN: grep {sizeof(bitFieldStruct) == 8} %t.out
+ // RUN: grep {Offset bitFieldStruct.i = 0} %t.out
+ // RUN: grep {Offset bitFieldStruct.c2 = 7} %t.out
+ // XFAIL: *
+
+ #include <stdio.h>
+
+ class bitFieldStruct {
+ public:
+ int i;
+ unsigned char c:7;
+ int s:17;
+ char c2;
+ };
+
+ int main()
+ {
+ printf("sizeof(bitFieldStruct) == %d\n", sizeof(bitFieldStruct));
+
+ if (sizeof(bitFieldStruct) != 2 * sizeof(int))
+ printf("bitFieldStruct should be %d but is %d \n",
+ 2 * sizeof(int), sizeof(bitFieldStruct));
+
+ bitFieldStruct x;
+
+ char* xip = (char*) &x.i;
+ char* xc2p = (char*) &x.c2;
+ printf("Offset bitFieldStruct.i = %d\n", xip - xip);
+ printf("Offset bitFieldStruct.c2 = %d\n", xc2p - xip);
+
+ return 0;
+ }
More information about the llvm-commits
mailing list