forked from OSchip/llvm-project
Fix crash initializing a bit-field with a non-constant in a place where we
try to evaluate the initializer as a constant. llvm-svn: 108632
This commit is contained in:
parent
2960987ddb
commit
3ee1022f37
|
@ -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.
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
|
||||
|
||||
int a();
|
||||
// CHECK: call i32 @_Z1av()
|
||||
struct x {int x, y : 10;} x = {1, a()};
|
Loading…
Reference in New Issue