[llvm-commits] CVS: llvm-test/SingleSource/Regression/C/PR491.c

Chris Lattner lattner at cs.uiuc.edu
Thu Oct 27 09:59:17 PDT 2005



Changes in directory llvm-test/SingleSource/Regression/C:

PR491.c added (r1.1)
---
Log message:

new testcase, from... PR491: http://llvm.cs.uiuc.edu/PR491 .


---
Diffs of the changes:  (+31 -0)

 PR491.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+)


Index: llvm-test/SingleSource/Regression/C/PR491.c
diff -c /dev/null llvm-test/SingleSource/Regression/C/PR491.c:1.1
*** /dev/null	Thu Oct 27 11:59:16 2005
--- llvm-test/SingleSource/Regression/C/PR491.c	Thu Oct 27 11:59:06 2005
***************
*** 0 ****
--- 1,31 ----
+ #include <stdio.h>
+ 
+ static int assert_fail(const char* s, unsigned l)
+ {
+     fprintf(stderr, "assertion failed in line %u: '%s'\n", l, s);
+     return 0;
+ }
+ #define ASSERT(expr)    ((expr) ? 1 : assert_fail(#expr,__LINE__))
+ 
+ int test(int r) {
+ #if !defined(__i386__)
+   #if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN)
+      return r;
+   #else
+      if (BYTE_ORDER != LITTLE_ENDIAN) return r;
+   #endif
+ #endif
+ 
+     /* little endian */
+     union { long l; unsigned char c[sizeof(long)]; } u;
+     u.l = 0; u.c[0] = 0x80;
+     r &= ASSERT(u.l == 128);
+     u.l = 0; u.c[sizeof(long)-1] = 0x80;
+     r &= ASSERT(u.l < 0);
+     return r;
+ }
+ 
+ int main() {
+     return test(1) == 1;
+ }
+ 






More information about the llvm-commits mailing list