summary refs log tree commit diff
path: root/test/vararg1.ssa
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2017-02-07 23:04:37 -0500
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2017-02-10 11:06:00 -0500
commitd9f1121763c126316ab338ca8b1b9d51967a33b1 (patch)
treed7fba7385fad59e8dc5bc5c9bd890d7de7400402 /test/vararg1.ssa
parentb99a8b0d07d43b89d5e27883ee5a9a67c2645809 (diff)
downloadroux-d9f1121763c126316ab338ca8b1b9d51967a33b1.tar.gz
tests for variable argument lists
Diffstat (limited to 'test/vararg1.ssa')
-rw-r--r--test/vararg1.ssa30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/vararg1.ssa b/test/vararg1.ssa
new file mode 100644
index 0000000..28b3d0e
--- /dev/null
+++ b/test/vararg1.ssa
@@ -0,0 +1,30 @@
+export
+function d $f(l %x, ...) {
+@start
+	%vp =l alloc8 24
+	vastart %vp
+	%i =l vaarg %vp
+	%n =d vaarg %vp
+	ret %n
+}
+
+export
+function w $g(l %fmt, ...) {
+@start
+	%vp =l alloc8 24
+	vastart %vp
+	%r =w call $vprintf(l %fmt, l %vp)
+	ret %r
+}
+
+# >>> driver
+# extern double f(int, ...);
+# extern int g(char *, ...);
+# int main() {
+# 	g("Hell%c %s %g!\n", 'o', "world", f(42, "x", 42.0));
+# }
+# <<<
+
+# >>> output
+# Hello world 42!
+# <<<