diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2010-07-17 23:55:01 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2010-07-17 23:55:01 +0000 |
commit | f0ca0ee66e5b1f3fc4d98e0d8795fa92559ce491 (patch) | |
tree | fd8648244437fda86d667ae5c5ff85b82daccdeb /lib/CodeGen/CGExprConstant.cpp | |
parent | 8d438087bd7120990663e4df78a9c9fdb02c5209 (diff) |
Fix crash initializing a bit-field with a non-constant in a place where we
try to evaluate the initializer as a constant.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108632 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index bbd256c4f1..4831b5dabe 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -81,10 +81,6 @@ AppendField(const FieldDecl *Field, uint64_t FieldOffset, assert(NextFieldOffsetInBytes <= FieldOffsetInBytes && "Field offset mismatch!"); - // Emit the field. - if (!InitCst) - return false; - unsigned FieldAlignment = getAlignment(InitCst); // Round up the field offset to the alignment of the field type. @@ -360,6 +356,9 @@ bool ConstStructBuilder::Build(InitListExpr *ILE) { Field->getType(), CGF); else EltInit = CGM.EmitNullConstant(Field->getType()); + + if (!EltInit) + return false; if (!Field->isBitField()) { // Handle non-bitfield members. |