From 001222523a8d3ed758761916d85432b8dde2b2c2 Mon Sep 17 00:00:00 2001 From: xleroy Date: Fri, 21 Jun 2013 07:41:32 +0000 Subject: Recognize attribute((packed)) after a "struct {...}" and not just between "struct" and "{", for compatibility with GCC. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2285 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- test/regression/Results/packedstruct1 | 4 ++++ test/regression/packedstruct1.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'test') diff --git a/test/regression/Results/packedstruct1 b/test/regression/Results/packedstruct1 index 0595cc3..e4bca76 100644 --- a/test/regression/Results/packedstruct1 +++ b/test/regression/Results/packedstruct1 @@ -19,3 +19,7 @@ sizeof(struct s5) = 14 offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 s5 = {x = 123, y = -456, z = 3.14159} +sizeof(struct s6) = 14 +offsetof(x) = 0, offsetof(y) = 2, offsetof(z) = 6 +s62 = {x = 123, y = -456, z = 3.14159} + diff --git a/test/regression/packedstruct1.c b/test/regression/packedstruct1.c index 66c8c9e..e7b6c1d 100644 --- a/test/regression/packedstruct1.c +++ b/test/regression/packedstruct1.c @@ -111,6 +111,20 @@ void test5(void) printf("s5 = {x = %d, y = %d, z = %.5f}\n\n", s5.x, s5.y, s5.z); } +/* Yet another, with packed attribute after the struct decl */ + +struct s6 { unsigned short x; int y; double z; } __attribute((packed)) const s61; + +void test6(void) +{ + struct s6 s62; + printf("sizeof(struct s6) = %d\n", sizeof(struct s6)); + printf("offsetof(x) = %d, offsetof(y) = %d, offsetof(z) = %d\n", + offsetof(s6,x), offsetof(s6,y), offsetof(s6,z)); + s62.x = 123; s62.y = -456; s62.z = 3.14159; + printf("s62 = {x = %d, y = %d, z = %.5f}\n\n", s62.x, s62.y, s62.z); +} + /* Test harness */ @@ -121,5 +135,6 @@ int main(int argc, char ** argv) test3(); test4(); test5(); + test6(); return 0; } -- cgit v1.2.3