summaryrefslogtreecommitdiff
path: root/test/regression
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
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')
-rw-r--r--test/regression/Results/struct74
-rw-r--r--test/regression/Results/struct82
-rw-r--r--test/regression/struct7.c59
-rw-r--r--test/regression/struct8.c23
4 files changed, 88 insertions, 0 deletions
diff --git a/test/regression/Results/struct7 b/test/regression/Results/struct7
new file mode 100644
index 0000000..ae630bf
--- /dev/null
+++ b/test/regression/Results/struct7
@@ -0,0 +1,4 @@
+A2 = { 1234, 3.141590, { 'H', ... , 'o' } }
+B2 = { 1, ..., 5, ..., 0 }
+C2.c = 'z'
+D2.v = { 0, ..., 4, ..., 0 }
diff --git a/test/regression/Results/struct8 b/test/regression/Results/struct8
new file mode 100644
index 0000000..a215193
--- /dev/null
+++ b/test/regression/Results/struct8
@@ -0,0 +1,2 @@
+a = { 123, 2.718000, 'a' }
+b = { 125, 5.436000, 'f' }
diff --git a/test/regression/struct7.c b/test/regression/struct7.c
new file mode 100644
index 0000000..136602b
--- /dev/null
+++ b/test/regression/struct7.c
@@ -0,0 +1,59 @@
+/* Assignment between structs and unions */
+
+#include <stdio.h>
+
+struct small {
+ int x;
+ double d;
+ char c[5];
+};
+
+struct big {
+ int x[100];
+};
+
+union u1 {
+ char c;
+ short s;
+};
+
+union u2 {
+ struct small u;
+ struct big v;
+};
+
+struct small A = { 1234, 3.14159, { 'H', 'e', 'l', 'l', 'o' }};
+struct big B = { 1, 2, 3, 4, 5 };
+union u1 C;
+union u2 D;
+
+int main()
+{
+ struct small A2;
+ struct big B2;
+ union u1 C2;
+ union u2 D2;
+ int i;
+
+ C.c = 'z';
+ for (i = 0; i < 99; i++) D.v.x[i] = i;
+
+ A2 = A;
+ printf("A2 = { %d, %f, { '%c', ... , '%c' } }\n",
+ A2.x, A2.d, A2.c[0], A2.c[4]);
+
+ B2 = B;
+ printf("B2 = { %d, ..., %d, ..., %d }\n",
+ B2.x[0], B2.x[4], B2.x[99]);
+
+ C2 = C;
+ printf("C2.c = '%c'\n", C2.c);
+
+ D2 = D;
+ printf("D2.v = { %d, ..., %d, ..., %d }\n",
+ D2.v.x[0], D2.v.x[4], D2.v.x[99]);
+
+ return 0;
+}
+
+
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;
+}