From 34e7946831a63f96d3ba3478c74ca8e25ee52d7e Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 28 Jan 2009 23:36:17 +0000 Subject: Improvements to code-generation and semantic analysis of designated initializers. - We now initialize unions properly when a member other than the first is named by a designated initializer. - We now provide proper semantic analysis and code generation for GNU array-range designators *except* that side effects will occur more than once. We warn about this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63253 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprConstant.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CGExprConstant.cpp') diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 87868ed347..b05048c946 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -246,12 +246,22 @@ public: // first field int FieldNo = 0; // Field no in RecordDecl FieldDecl* curField = 0; + bool sawAnyFields = false; for (RecordDecl::field_iterator Field = RD->field_begin(), FieldEnd = RD->field_end(); Field != FieldEnd; ++Field) { curField = *Field; FieldNo++; - if (curField->getIdentifier()) + + if (curField->isUnnamedBitfield()) + continue; + + // If we have an initializer, find the field whose type is the + // same as that initializer. This + sawAnyFields = true; + if (ILE->getNumInits() > 0 && + CGM.getContext().getCanonicalType(curField->getType()) == + CGM.getContext().getCanonicalType(ILE->getInit(0)->getType())) break; } -- cgit v1.2.3