Skip to content

Commit 3fbca9a

Browse files
committed
Revert back to previous strategy to fix failing tests
1 parent afcda23 commit 3fbca9a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

clang/lib/Sema/SemaInit.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,11 +2402,8 @@ void InitListChecker::CheckStructUnionTypes(
24022402
CheckEmptyInitializable(
24032403
InitializedEntity::InitializeMember(*Field, &Entity),
24042404
IList->getEndLoc());
2405-
if (StructuredList) {
2405+
if (StructuredList)
24062406
StructuredList->setInitializedFieldInUnion(*Field);
2407-
StructuredList->resizeInits(SemaRef.Context,
2408-
StructuredList->getNumInits() + 1);
2409-
}
24102407
break;
24112408
}
24122409
}
@@ -3032,10 +3029,11 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
30323029
if (StructuredList) {
30333030
FieldDecl *CurrentField = StructuredList->getInitializedFieldInUnion();
30343031
if (CurrentField && !declaresSameEntity(CurrentField, *Field)) {
3035-
assert(StructuredList->getNumInits() == 1
3036-
&& "A union should never have more than one initializer!");
3032+
const auto NumInits = StructuredList->getNumInits();
3033+
assert(StructuredList->getNumInits() <= 1 &&
3034+
"A union should never have more than one initializer!");
30373035

3038-
Expr *ExistingInit = StructuredList->getInit(0);
3036+
Expr *ExistingInit = NumInits ? StructuredList->getInit(0) : nullptr;
30393037
if (ExistingInit) {
30403038
// We're about to throw away an initializer, emit warning.
30413039
diagnoseInitOverride(

0 commit comments

Comments
 (0)