[llvm-commits] CVS: llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c
Vikram Adve
vadve at cs.uiuc.edu
Sun May 25 10:58:01 PDT 2003
Changes in directory llvm/test/Programs/SingleSource/UnitTests:
2003-05-07-VarArgs.c updated: 1.3 -> 1.4
---
Log message:
Add tests for passing structures by value through varargs.
Also modify test to pass more arguments than fit in the argument registers.
---
Diffs of the changes:
Index: llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c
diff -u llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c:1.3 llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c:1.4
--- llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c:1.3 Thu May 8 14:43:55 2003
+++ llvm/test/Programs/SingleSource/UnitTests/2003-05-07-VarArgs.c Sun May 25 10:56:54 2003
@@ -1,10 +1,23 @@
#include <stdio.h>
#include <stdarg.h>
+/* 5 bytes. */
+typedef struct DWordS_struct { int i; char c; } DWordS;
+
+/* 12 bytes if d is 4-byte aligned; 16 bytes if d is 8-byte aligned. */
+typedef struct QuadWordS_struct { int i; double d; } QuadWordS;
+
+/* 20 bytes if d is 4-byte aligned; 28 bytes if d is 8-byte aligned
+ * (assuming pointer size is 4 bytes and 8 bytes respectively). */
+typedef struct LargeS_struct { int i; double d; DWordS* ptr; int j; } LargeS;
+
void test(char *fmt, ...) {
va_list ap, aq;
int d;
char c, *s;
+ DWordS dw;
+ QuadWordS qw;
+ LargeS ls;
va_start(ap, fmt);
@@ -33,14 +46,35 @@
c = (char) va_arg(ap, int);
printf("char %c\n", c);
break;
+ case 'D':
+ /* dw = va_arg(ap, DWordS);
+ printf("DWord { %d, %c }\n", dw.i, dw.c);
+ */ break;
+ case 'Q':
+ /* qw = va_arg(ap, QuadWordS);
+ printf("QuadWord { %d, %f }\n", qw.i, qw.d);
+ */ break;
+ case 'L':
+ /* ls = va_arg(ap, LargeS);
+ printf("LargeS { %d, %f, 0x%p, %d }\n", ls.i, ls.d, ls.ptr, ls.j);
+ */ break;
}
va_end(ap);
}
int main() {
- test("ssici", "abc", "def", -123, 'a', 123);
+ DWordS dw = { 18, 'a' };
+ DWordS dw2;
+ QuadWordS qw = { 19, 20.0 };
+ LargeS ls = { 21, 22.0, &dw, 23 };
+
+ test("ssiciiiiis", "abc", "def", -123, 'a', 123, 6, 7, 8, 9, "10 args done!");
/* test promotion & 64-bit types */
test("ddil", 1.0, 2.0f, (short)32764, 12345677823423LL);
+
+ /* test passing structs by value to varargs */
+ test("DQL", dw2, qw, ls);
+
return 0;
}
More information about the llvm-commits
mailing list