forked from OSchip/llvm-project
Fix initialization for members of anonymous struct in a union.
llvm-svn: 111159
This commit is contained in:
parent
33aee3934a
commit
a3ae3eb690
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue