From fe1bc708b53016d0800b54342b268c09b8c52a6f Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 8 Apr 2016 19:57:40 +0000 Subject: [modules] Handle merged fields in designated initializers. llvm-svn: 265838 --- clang/lib/Sema/SemaInit.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'clang/lib/Sema/SemaInit.cpp') diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index bd8522d5977..81b5312d87a 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -2227,8 +2227,10 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, for (auto *FI : RT->getDecl()->fields()) { if (FI->isUnnamedBitfield()) continue; - if (KnownField == FI) + if (declaresSameEntity(KnownField, FI)) { + KnownField = FI; break; + } ++FieldIndex; } @@ -2241,11 +2243,11 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, FieldIndex = 0; if (!VerifyOnly) { FieldDecl *CurrentField = StructuredList->getInitializedFieldInUnion(); - if (CurrentField && CurrentField != *Field) { + if (CurrentField && !declaresSameEntity(CurrentField, *Field)) { assert(StructuredList->getNumInits() == 1 && "A union should never have more than one initializer!"); - // we're about to throw away an initializer, emit warning + // We're about to throw away an initializer, emit warning. SemaRef.Diag(D->getFieldLoc(), diag::warn_initializer_overrides) << D->getSourceRange(); -- cgit v1.2.3