summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/const-init.c
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-10-19 23:40:06 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-10-19 23:40:06 +0000
commit8e133965c8ff3063a50c118c3797a5d7bb4fc75f (patch)
tree26366f3cc049f98621e3189eb5d9af0ed1e5cdd3 /clang/test/CodeGen/const-init.c
parentc4df33be5af658c3ef5316bb6dc4cb370ec9a138 (diff)
downloadbcm5719-llvm-8e133965c8ff3063a50c118c3797a5d7bb4fc75f.tar.gz
bcm5719-llvm-8e133965c8ff3063a50c118c3797a5d7bb4fc75f.zip
CodeGen: ConstStructBuilder must verify packed constraints after padding
This reverts commit r220169 which reverted r220153. However, it also contains additional changes: - We may need to add padding *after* we've packed the struct. This occurs when the aligned next field offset is greater than the new field's offset. When this occurs, we make the struct packed. *However*, once packed the next field offset might be less than the new feild's offset. It is in this case that we might further pad the struct. - We would pad structs which were perfectly sized! This behavior is immensely old. This behavior came from blindly subtracting NextFieldOffsetInChars from RecordSize. This doesn't take into account the fact that the struct might have a greater overall alignment than the last field. llvm-svn: 220175
Diffstat (limited to 'clang/test/CodeGen/const-init.c')
-rw-r--r--clang/test/CodeGen/const-init.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/test/CodeGen/const-init.c b/clang/test/CodeGen/const-init.c
index 7d7ccae370d..b86274fc824 100644
--- a/clang/test/CodeGen/const-init.c
+++ b/clang/test/CodeGen/const-init.c
@@ -159,3 +159,25 @@ void g29() {
static int b[1] = { "asdf" }; // expected-warning {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'char [5]'}}
static int c[1] = { L"a" };
}
+
+// PR21300
+void g30() {
+#pragma pack(1)
+ static struct {
+ int : 1;
+ int x;
+ } a = {};
+ // CHECK: @g30.a = internal global %struct.anon.1 <{ i8 undef, i32 0 }>, align 1
+#pragma pack()
+}
+
+void g31() {
+#pragma pack(4)
+ static struct {
+ short a;
+ long x;
+ short z;
+ } a = {23122, -12312731, -312};
+#pragma pack()
+ // CHECK: @g31.a = internal global %struct.anon.2 { i16 23122, i32 -12312731, i16 -312 }, align 4
+}
OpenPOWER on IntegriCloud