From 7e378c0215c99d7f8bd38341081ec04fd202fd0a Mon Sep 17 00:00:00 2001 From: xleroy Date: Sun, 16 Oct 2011 07:37:28 +0000 Subject: Revised emulation of packed structs git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1729 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- test/regression/Results/packedstruct1 | 4 ++-- test/regression/packedstruct1.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/regression/Results/packedstruct1 b/test/regression/Results/packedstruct1 index fe19bff..7549132 100644 --- a/test/regression/Results/packedstruct1 +++ b/test/regression/Results/packedstruct1 @@ -7,8 +7,8 @@ sizeof(struct s2) = 16 offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 s2 = {x = 57, y = -456, z = 3.14159} -sizeof(struct s3) = 13 -s3 = {x = 123, y = 45678, z = 2147483649, v = -456, w = -1234567} +sizeof(struct s3) = 29 +s3 = {x = 123, y = 45678, z = 2147483649, v = -456, w = -1234567, p is ok, t = {111,222,333}} sizeof(struct s4) = 16 offsetof(x) = 0, offsetof(y) = 4, offsetof(z) = 8 diff --git a/test/regression/packedstruct1.c b/test/regression/packedstruct1.c index 1bde780..cecd1f3 100644 --- a/test/regression/packedstruct1.c +++ b/test/regression/packedstruct1.c @@ -50,20 +50,30 @@ struct s3 { unsigned int z; signed short v; signed int w; + char * p; + unsigned int t[3]; }; struct s3 s3; void test3(void) { + char xx; + printf("sizeof(struct s3) = %d\n", sizeof(struct s3)); s3.x = 123; s3.y = 45678; s3.z = 0x80000001U; s3.v = -456; s3.w = -1234567; - printf("s3 = {x = %u, y = %u, z = %u, v = %d, w = %d}\n\n", - s3.x, s3.y, s3.z, s3.v, s3.w); + s3.p = &xx; + s3.t[0] = 111; + s3.t[1] = 222; + s3.t[2] = 333; + printf("s3 = {x = %u, y = %u, z = %u, v = %d, w = %d, p is %s, t = {%d,%d,%d}}\n\n", + s3.x, s3.y, s3.z, s3.v, s3.w, + (s3.p == &xx ? "ok" : "BAD"), + s3.t[0], s3.t[1], s3.t[2]); } /* Back to normal */ -- cgit v1.2.3