[cfe-commits] r63253 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.def lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CGExprConstant.cpp lib/CodeGen/CodeGenTypes.cpp lib/Sema/Sema.h lib/Sema/SemaInit.cpp test/Sema/designated-initializers.c

Douglas Gregor dgregor at apple.com
Thu Jan 29 08:56:06 PST 2009


On Jan 28, 2009, at 5:31 PM, Eli Friedman wrote:

> On Wed, Jan 28, 2009 at 3:36 PM, Douglas Gregor <dgregor at apple.com>  
> wrote:
>> +    // When we're coping with C99 designated initializers into a
>> +    // union, find the field that has the same type as the  
>> expression
>> +    // we're initializing the union with.
>> +    if (isUnion && CurInitVal < NumInitElements &&
>> +        (CGF.getContext().getCanonicalType(Field->getType()) !=
>> +           CGF.getContext().getCanonicalType(E- 
>> >getInit(CurInitVal)->getType())))
>> +      continue;
>
> This is kind of messy.

Yes, it is messy... I've decided to annotate InitListExprs for unions  
with the FieldDecl that should be initialized. Semantic analysis fills  
in this value, and CodeGen can blindly follow it.

	- Doug



More information about the cfe-commits mailing list