aboutsummaryrefslogtreecommitdiffstats
path: root/test/regression/varargs2.c
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2015-03-20 16:43:14 +0100
committerXavier Leroy <xavier.leroy@inria.fr>2015-03-20 16:43:14 +0100
commita90ffe0a21a3a813df4eb9a4dc23b06f50699cde (patch)
tree7b2bc56cb7ca16314a3cc4503a61ec6d42bdb9db /test/regression/varargs2.c
parent375244b93979a4ea238d5dc31211209a60a459b1 (diff)
downloadcompcert-kvx-a90ffe0a21a3a813df4eb9a4dc23b06f50699cde.tar.gz
compcert-kvx-a90ffe0a21a3a813df4eb9a4dc23b06f50699cde.zip
Support va_arg for vararg arguments of composite (struct/union) types.
ARM is done, IA32 and PowerPC remain to be updated.
Diffstat (limited to 'test/regression/varargs2.c')
-rw-r--r--test/regression/varargs2.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/regression/varargs2.c b/test/regression/varargs2.c
index 6c091d8b..b96d1940 100644
--- a/test/regression/varargs2.c
+++ b/test/regression/varargs2.c
@@ -1,6 +1,9 @@
#include <stdarg.h>
#include <stdio.h>
+struct Y { char kind; unsigned char num; };
+struct Z { int x, y, z; };
+
void minivprintf(const char * fmt, va_list ap)
{
char c;
@@ -32,6 +35,14 @@ void minivprintf(const char * fmt, va_list ap)
case 'f':
printf("%.10g", (float) va_arg(ap, double));
break;
+ case 'y':
+ { struct Y s = va_arg(ap, struct Y);
+ printf("%c%d", s.kind, s.num);
+ break; }
+ case 'z':
+ { struct Z s = va_arg(ap, struct Z);
+ printf("(%d,%d,%d)", s.x, s.y, s.z);
+ break; }
default:
puts("<bad format>");
return;
@@ -111,9 +122,12 @@ int main()
miniprintf("A long long: %l\n", 123456789012345LL);
miniprintf("A string: %s\n", "Hello world");
miniprintf("A double: %e\n", 3.141592654);
- miniprintf("A mixture: %c & %s & %d & %l & %e & %f\n",
+ miniprintf("A small struct: %y\n", (struct Y) { 'x', 12 });
+ miniprintf("A bigger struct: %z\n", (struct Z) { 123, 456, 789 });
+ miniprintf("A mixture: %c & %s & %y & %d & %l & %e & %f\n",
'x',
"Hello, world!",
+ (struct Y) { 'y', 2 },
42,
123456789012345LL,
3.141592654,