diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-10-19 00:03:10 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-10-19 00:03:10 +0000 |
commit | 9fd8cd1b673daf4ff485b01c1980d917f789ef81 (patch) | |
tree | 44b980f89bcb0b2738422ef36848b53cdd90cd2d /test/CodeGen/const-init.c | |
parent | bacc8fd5ad2a070aedff6e1c5f425154f866460c (diff) |
CodeGen: ConstStructBuilder must verify packed constraints after padding
Before, ConstStructBuilder::AppendBytes would check packed constraints
prior to padding being added before the field's offset. However, adding
this padding might force our struct to be packed. Because we wouldn't
check *after* adding padding, ConstStructBuilder would be in an
inconsistent state leading to a crash.
This fixes PR21300.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220153 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/const-init.c')
-rw-r--r-- | test/CodeGen/const-init.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/CodeGen/const-init.c b/test/CodeGen/const-init.c index 7d7ccae370..ccc6604c45 100644 --- a/test/CodeGen/const-init.c +++ b/test/CodeGen/const-init.c @@ -159,3 +159,14 @@ 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() +} |