summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-06-21 07:41:32 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-06-21 07:41:32 +0000
commit001222523a8d3ed758761916d85432b8dde2b2c2 (patch)
tree8206e5b30d9b4ee86093d576a833e93615cb060e /test
parent794b0530851265d08e369ff2eaf791b47b48c829 (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/regression/Results/packedstruct14
-rw-r--r--test/regression/packedstruct1.c15
2 files changed, 19 insertions, 0 deletions
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;
}