summaryrefslogtreecommitdiff
path: root/test/Sema/struct-packed-align.c
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-02-16 19:51:36 +0000
committerAnders Carlsson <andersca@mac.com>2008-02-16 19:51:36 +0000
commit5a1b0c4d91bd2d846f91121ffd71508b7bb7ddf6 (patch)
tree3d7b243e8271be42514e5745101a625484ea2383 /test/Sema/struct-packed-align.c
parent042c4e7e9f0b54104f4f2e098c028aa8247b6bed (diff)
downloadclang-5a1b0c4d91bd2d846f91121ffd71508b7bb7ddf6.tar.gz
Add more tests
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47217 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/struct-packed-align.c')
-rw-r--r--test/Sema/struct-packed-align.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/test/Sema/struct-packed-align.c b/test/Sema/struct-packed-align.c
index 23885a5461..f718343563 100644
--- a/test/Sema/struct-packed-align.c
+++ b/test/Sema/struct-packed-align.c
@@ -1,5 +1,6 @@
// RUN: clang %s -fsyntax-only -verify
+// Packed structs.
struct s {
char a;
int b __attribute__((packed));
@@ -7,6 +8,9 @@ struct s {
int d;
};
+extern int a1[sizeof(struct s) == 12 ? 1 : -1];
+extern int a2[__alignof(struct s) == 4 ? 1 : -1];
+
struct __attribute__((packed)) packed_s {
char a;
int b __attribute__((packed));
@@ -14,24 +18,47 @@ struct __attribute__((packed)) packed_s {
int d;
};
+extern int b1[sizeof(struct packed_s) == 10 ? 1 : -1];
+extern int b2[__alignof(struct packed_s) == 1 ? 1 : -1];
+
struct fas {
char a;
int b[];
};
+extern int c1[sizeof(struct fas) == 4 ? 1 : -1];
+extern int c2[__alignof(struct fas) == 4 ? 1 : -1];
+
struct __attribute__((packed)) packed_fas {
char a;
int b[];
};
-extern int a1[sizeof(struct s) == 12 ? 1 : -1];
-extern int a2[__alignof(struct s) == 4 ? 1 : -1];
+extern int d1[sizeof(struct packed_fas) == 1 ? 1 : -1];
+extern int d2[__alignof(struct packed_fas) == 1 ? 1 : -1];
-extern int b1[sizeof(struct packed_s) == 10 ? 1 : -1];
-extern int b2[__alignof(struct packed_s) == 1 ? 1 : -1];
+// Alignment
-extern int c1[sizeof(struct fas) == 4 ? 1 : -1];
-extern int c2[__alignof(struct fas) == 4 ? 1 : -1];
+struct __attribute__((aligned(8))) as1 {
+ char c;
+};
-extern int d1[sizeof(struct packed_fas) == 1 ? 1 : -1];
-extern int d2[__alignof(struct packed_fas) == 1 ? 1 : -1];
+extern int e1[sizeof(struct as1) == 8 ? 1 : -1];
+extern int e2[__alignof(struct as1) == 8 ? 1 : -1];
+
+struct as2 {
+ char c;
+ int __attribute__((aligned(8))) a;
+};
+
+extern int f1[sizeof(struct as2) == 16 ? 1 : -1];
+extern int f2[__alignof(struct as2) == 8 ? 1 : -1];
+
+struct __attribute__((packed)) as3 {
+ char c;
+ int a;
+ int __attribute__((aligned(8))) b;
+};
+
+extern int g1[sizeof(struct as3) == 16 ? 1 : -1];
+extern int g2[__alignof(struct as3) == 8 ? 1 : -1];