aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-10-27 17:14:03 +0000
committerChris Lattner <sabre@nondot.org>2005-10-27 17:14:03 +0000
commit7c05e3ffe02e5eefd197426223370928da8b8aad (patch)
treee6e1e66877e2e498ae8d02af4fd81a8253bdf9ab
parentc9409e10d07737c335b7a73a22d3552f5413738b (diff)
New testcase
git-svn-id: https://llvm.org/svn/llvm-project/test-suite/trunk@24047 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--SingleSource/Regression/C/PR640.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/SingleSource/Regression/C/PR640.c b/SingleSource/Regression/C/PR640.c
new file mode 100644
index 00000000..97d2a020
--- /dev/null
+++ b/SingleSource/Regression/C/PR640.c
@@ -0,0 +1,56 @@
+#include <stdarg.h>
+#include <stdio.h>
+
+static int test_stdarg_va(void* p1, ...)
+{
+ va_list ap;
+ unsigned long l;
+ int i1, i2;
+ void* p2;
+ va_start(ap, p1);
+ i1 = va_arg(ap, int);
+ l = va_arg(ap, unsigned long);
+ i2 = va_arg(ap, int);
+ p2 = va_arg(ap, void *);
+ va_end(ap);
+ return p1 == p2 && i1 == 1 && l == 0x76214365ul && i2 == 2;
+}
+
+
+static int test_stdarg_builtin_va(void* p1, ...)
+{
+ __builtin_va_list ap;
+ unsigned long l;
+ int i1, i2;
+ void* p2;
+ __builtin_stdarg_start(ap, p1);
+ i1 = __builtin_va_arg(ap, int);
+ l = __builtin_va_arg(ap, unsigned long);
+ i2 = __builtin_va_arg(ap, int);
+ p2 = __builtin_va_arg(ap, void *);
+ __builtin_va_end(ap);
+ return p1 == p2 && i1 == 1 && l == 0x76214369ul && i2 == 2;
+}
+
+
+static int test_stdarg(int r)
+{
+ char c1 = 1, c2 = 2;
+ if (test_stdarg_va(&r, c1, 0x76214365ul, c2, &r) != 1)
+ return 0;
+ if (test_stdarg_builtin_va(&r, c1, 0x76214369ul, c2, &r) != 1)
+ return 0;
+ return r & 1;
+}
+
+
+int main(int argc, char **argv)
+{
+ if (test_stdarg(1) != 1) {
+ printf("ERROR\n");
+ return 1;
+ }
+ printf("All done.\n");
+ return 0;
+}
+