From a9a6d92cbf3371de82aa81595564c23986b4da89 Mon Sep 17 00:00:00 2001 From: xleroy Date: Sat, 17 Apr 2010 07:41:39 +0000 Subject: __builtin_memcpy, continued. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1320 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- test/regression/struct8.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/regression/struct8.c (limited to 'test/regression/struct8.c') diff --git a/test/regression/struct8.c b/test/regression/struct8.c new file mode 100644 index 00000000..989c3524 --- /dev/null +++ b/test/regression/struct8.c @@ -0,0 +1,23 @@ +/* Passing structs by value */ + +#include + +struct S { int x; double d; char c; }; + +struct S f(struct S s, int scale) +{ + struct S r; + r.x = s.x + scale; + r.d = s.d * scale; + r.c = 'f'; + return r; +} + +int main() +{ + struct S a = { 123, 2.718, 'a' }; + struct S b = f(a, 2); + printf("a = { %d, %f, '%c' }\n", a.x, a.d, a.c); + printf("b = { %d, %f, '%c' }\n", b.x, b.d, b.c); + return 0; +} -- cgit