summary refs log tree commit diff stats
path: root/tests/ccgbugs/tcvarargs.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ccgbugs/tcvarargs.nim')
-rw-r--r--tests/ccgbugs/tcvarargs.nim35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/ccgbugs/tcvarargs.nim b/tests/ccgbugs/tcvarargs.nim
new file mode 100644
index 000000000..261885f4f
--- /dev/null
+++ b/tests/ccgbugs/tcvarargs.nim
@@ -0,0 +1,35 @@
+discard """
+  output: '''17
+17
+17
+17
+17
+17
+'''
+"""
+
+# bug #1593
+
+{.emit: """
+#include <stdarg.h>
+#include <stdio.h>
+
+void foo(int n, ...) {
+  NI64 k;
+  int i;
+  va_list argp;
+  va_start(argp, n);
+  for (i = 1; i <= n; i++) {
+    k = va_arg(argp, NI64);
+    printf("%lld\n", (long long)k);
+  }
+  va_end(argp);
+}
+""".}
+
+proc foo(x: cint) {.importc, varargs, nodecl.}
+
+proc main() =
+  const k = 17'i64
+  foo(6, k, k, k, k, k, k)
+main()