shithub: scc

Download patch

ref: 8217c283951a053da7a26fd7dd03d66e14a71205
parent: 68ac0fbe04cbc204f37169fc924ce4783b76e15c
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Mar 23 08:57:25 EDT 2022

tests/cc: Add 0202-variadic.c

--- /dev/null
+++ b/tests/cc/execute/0202-variadic.c
@@ -1,0 +1,44 @@
+#define debug1(...)    test1(__VA_ARGS__)
+#define debug2(...)    test2(0, #__VA_ARGS__)
+#define debug3(t, ...) ((t==1) ? test1(__VA_ARGS__):test2(__VA_ARGS__))
+
+int
+test1(int x, char *s)
+{
+	int i;
+
+	if (x != 3)
+		return 0;
+	for (i = 0; s[i]; i++) {
+		if (s[i] != "test1"[i])
+			return 0;
+	}
+	return 1;
+}
+
+int
+test2(int x, char *s)
+{
+	int i;
+
+	for (i = 0; s[i]; i++) {
+		if (s[i] != "1, 2"[i])
+			return 0;
+	}
+	return 1;
+}
+
+int
+main()
+{
+	if (!debug1(3, "test1"))
+		return 1;
+	if (!debug2(1, 2))
+		return 2;
+	if (!debug3(1, 3, "test1"))
+		return 3;
+	if (!debug3(2, 0, "1, 2"))
+		return 4;
+
+	return 0;
+}
--- a/tests/cc/execute/scc-tests.lst
+++ b/tests/cc/execute/scc-tests.lst
@@ -192,3 +192,4 @@
 0199-voidpcast.c [TODO]
 0200-cpp.c [TODO]
 0201-cpp.c [TODO]
+0202-variadic.c [TODO]