scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 5c18e618e075ee090ca30a507da86c87d7fd4295
parent 612c1e5c2597e481ef27bdd33b771656590e7052
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  4 Nov 2022 05:42:48 +0100

test/cc: Add execute/0215-ret_struct.c

Diffstat:
Atests/cc/execute/0215-ret_struct.c | 36++++++++++++++++++++++++++++++++++++
Mtests/cc/execute/scc-tests.lst | 1+
2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/tests/cc/execute/0215-ret_struct.c b/tests/cc/execute/0215-ret_struct.c @@ -0,0 +1,36 @@ +struct f { + char fill[40]; + int a; +}; + +struct f +f1(struct f a) +{ + a.a += 2; + return a; +} + +struct f +f2(struct f a) +{ + struct f b; + + b.a = a.a + 2; + return b; +} + +int +main() +{ + struct f a, b; + + a.a = 1; + b = f1(a); + if (b.a != a.a + 2) + return 1; + b = f2(a); + if (b.a != a.a + 2) + return 2; + + return 0; +} diff --git a/tests/cc/execute/scc-tests.lst b/tests/cc/execute/scc-tests.lst @@ -205,3 +205,4 @@ 0212-krtypes.c 0213-decay.c [TODO] 0214-va_copy.c +0215-ret_struct.c