Fix initialization for members of anonymous struct in a union.

llvm-svn: 111159
This commit is contained in:
Argyrios Kyrtzidis 2010-08-16 17:27:13 +00:00
parent 33aee3934a
commit a3ae3eb690
2 changed files with 15 additions and 0 deletions

View File

@ -1798,6 +1798,9 @@ static bool CollectFieldInitializer(BaseAndFieldInfo &Info,
// Once we've initialized a field of an anonymous union, the union
// field in the class is also initialized, so exit immediately.
return false;
} else if ((*FA)->isAnonymousStructOrUnion()) {
if (CollectFieldInitializer(Info, Top, *FA))
return true;
}
}

View File

@ -78,3 +78,15 @@ namespace test3 {
// CHECK-NEXT: [[CVALUE:%.*]] = getelementptr inbounds {{.*}} [[STRUCT]], i32 0, i32 0
// CHECK-NEXT: store i8* null, void i8** [[CVALUE]]
}
struct S {
// CHECK: store i32 42
// CHECK: store i32 55
S() : x(42), y(55) {}
union {
struct {
int x;
union { int y; };
};
};
} s;