[hackers] [scc] Add basic test for vararg functions || Roberto E. Vargas Caballero
commit 2adcda7668e73c5fd1471f0766fd6fd3ba8d638b
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Sep 28 16:21:20 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Sep 28 16:21:20 2015 +0200
Add basic test for vararg functions
diff --git a/cc1/tests/test030.c b/cc1/tests/test030.c
new file mode 100644
index 0000000..cde5243
--- /dev/null
+++ b/cc1/tests/test030.c
_AT_@ -0,0 +1,60 @@
+
+/*
+name: TEST030
+description: Basic test for vararg functions
+output:
+F13 I S2 P I E
+G14 F13 f1
+{
+S2 foo
+M3 I i
+M4 I j
+M5 I k
+M7 P p
+M8 J v
+A9 S2 f
+A11 P p
+A12 I n
+\
+ j L15 A9 M3 .I A11 _AT_S2 M3 .I =I
+ r #I0
+L15
+ r A11 _AT_S2 M4 .I A12 +I
+}
+F16 I
+G17 F16 main
+{
+\
+A18 S2 f
+ A18 M3 .I A18 M4 .I #I1 :I :I
+ G14 A18 pS2 A18 'P pP #I2 pI cI
+ G14 A18 pS2 A18 'P pP #I2 pI #I1 pI A18 pS2 A18 'P pP cI
+ r #I0
+}
+*/
+
+struct foo {
+ int i, j, k;
+ char *p;
+ float v;
+};
+
+int
+f1(struct foo f, struct foo *p, int n, ...)
+{
+ if (f.i != p->i)
+ return 0;
+ return p->j + n;
+}
+
+int
+main(void)
+{
+ struct foo f;
+
+ f.i = f.j = 1;
+ f1(f, &f, 2);
+ f1(f, &f, 2, 1, f, &f);
+
+ return 0;
+}
Received on Mon Sep 28 2015 - 17:27:57 CEST
This archive was generated by hypermail 2.3.0
: Mon Sep 28 2015 - 17:36:12 CEST