Fix an assertion when initializing a union using a member initializer. (We weren't casting from the union type to the initializer type correctly).

llvm-svn: 80837
This commit is contained in:
Anders Carlsson 2009-09-02 21:14:47 +00:00
parent 3a964ebdc4
commit 35dca26835
2 changed files with 14 additions and 1 deletions

View File

@ -1658,7 +1658,8 @@ void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD) {
else {
// Initializing an anonymous union data member.
FieldDecl *anonMember = Member->getAnonUnionMember();
LHS = EmitLValueForField(LHS.getAddress(), anonMember, false, 0);
LHS = EmitLValueForField(LHS.getAddress(), anonMember,
/*IsUnion=*/true, 0);
FieldType = anonMember->getType();
}
}

View File

@ -0,0 +1,12 @@
// RUN: clang-cc -emit-llvm -o - %s
struct A {
union {
int a;
void* b;
};
A() : a(0) { }
};
A a;