Code generation support for C99 designated initializers.

The approach I've taken in this patch is relatively straightforward,
although the code itself is non-trivial. Essentially, as we process
an initializer list we build up a fully-explicit representation of the
initializer list, where each of the subobject initializations occurs
in order. Designators serve to "fill in" subobject initializations in
a non-linear way. The fully-explicit representation makes initializer
lists (both with and without designators) easy to grok for codegen and
later semantic analyses. We keep the syntactic form of the initializer
list linked into the AST for those clients interested in exactly what
the user wrote.

Known limitations:
  - Designating a member of a union that isn't the first member may
    result in bogus initialization (we warn about this)
  - GNU array-range designators are not supported (we warn about this)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63242 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp
index 9181bf6..2534a14 100644
--- a/lib/CodeGen/CGExprAgg.cpp
+++ b/lib/CodeGen/CGExprAgg.cpp
@@ -71,7 +71,7 @@
   void VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
     EmitAggLoadOfLValue(E);
   }
-
+  
   // Operators.
   //  case Expr::UnaryOperatorClass:
   //  case Expr::CastExprClass: 
@@ -303,11 +303,6 @@
 }
 
 void AggExprEmitter::EmitNonConstInit(InitListExpr *E) {
-  if (E->hadDesignators()) {
-    CGF.ErrorUnsupported(E, "initializer list with designators");
-    return;
-  }
-  
   const llvm::PointerType *APType =
     cast<llvm::PointerType>(DestPtr->getType());
   const llvm::Type *DestType = APType->getElementType();
@@ -346,6 +341,8 @@
   // FIXME: Are initializers affected by volatile?
   if (E->getType()->isComplexType()) {
     CGF.EmitComplexExprIntoAddr(E, LV.getAddress(), false);
+  } else if (isa<CXXZeroInitValueExpr>(E)) {
+    EmitNullInitializationToLValue(LV, E->getType());
   } else if (CGF.hasAggregateLLVMType(E->getType())) {
     CGF.EmitAnyExpr(E, LV.getAddress(), false);
   } else {
@@ -380,11 +377,6 @@
 }
 
 void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
-  if (E->hadDesignators()) {
-    CGF.ErrorUnsupported(E, "initializer list with designators");
-    return;
-  }
-
 #if 0
   // FIXME: Disabled while we figure out what to do about 
   // test/CodeGen/bitfield.c
@@ -426,7 +418,7 @@
 
     uint64_t NumArrayElements = AType->getNumElements();
     QualType ElementType = CGF.getContext().getCanonicalType(E->getType());
-    ElementType =CGF.getContext().getAsArrayType(ElementType)->getElementType();
+    ElementType = CGF.getContext().getAsArrayType(ElementType)->getElementType();
     
     unsigned CVRqualifier = ElementType.getCVRQualifiers();
 
@@ -479,7 +471,7 @@
     }
 
     // Unions only initialize one field.
-    // (things can get weird with designators, but they aren't
+    // (FIXME: things can get weird with designators, but they aren't
     // supported yet.)
     if (isUnion)
       break;