summaryrefslogtreecommitdiff
path: root/test/regression/struct7.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/struct7.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/struct7.c')
-rw-r--r--test/regression/struct7.c59
1 files changed, 59 insertions, 0 deletions
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;
+}
+
+