scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 2adcda7668e73c5fd1471f0766fd6fd3ba8d638b
parent c4e05cd31ffe16a2f49bd611d300841ef6435642
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 28 Sep 2015 16:21:20 +0200

Add basic test for vararg functions

Diffstat:
Acc1/tests/test030.c | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+), 0 deletions(-)

diff --git a/cc1/tests/test030.c b/cc1/tests/test030.c @@ -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 @S2 M3 .I =I + r #I0 +L15 + r A11 @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; +}