summaryrefslogtreecommitdiff
path: root/test/regression/struct8.c
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-04-17 07:41:39 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-04-17 07:41:39 +0000
commita9a6d92cbf3371de82aa81595564c23986b4da89 (patch)
treeedd86e6cb6a355ac867f13edcbcc4dc467c30c5d /test/regression/struct8.c
parent59646439baa1b9cc6209b684e4ccf9aac908fdbc (diff)
__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.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/regression/struct8.c b/test/regression/struct8.c
new file mode 100644
index 0000000..989c352
--- /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;
+}