diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2010-04-17 07:41:39 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2010-04-17 07:41:39 +0000 |
commit | a9a6d92cbf3371de82aa81595564c23986b4da89 (patch) | |
tree | edd86e6cb6a355ac867f13edcbcc4dc467c30c5d /test/regression/struct8.c | |
parent | 59646439baa1b9cc6209b684e4ccf9aac908fdbc (diff) | |
download | compcert-a9a6d92cbf3371de82aa81595564c23986b4da89.tar.gz compcert-a9a6d92cbf3371de82aa81595564c23986b4da89.zip |
__builtin_memcpy, continued.
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1320 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/regression/struct8.c')
-rw-r--r-- | test/regression/struct8.c | 23 |
1 files changed, 23 insertions, 0 deletions
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 <stdio.h> + +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; +} |