]> granicus.if.org Git - clang/commitdiff
make codegen reject initializes with designators, like this:
authorChris Lattner <sabre@nondot.org>
Sun, 26 Oct 2008 23:53:12 +0000 (23:53 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 26 Oct 2008 23:53:12 +0000 (23:53 +0000)
t.c:1:13: error: cannot codegen this designators yet
int a[10] = {2, 4, [8]=9, 10};
            ^~~~~~~~~~~~~~~~~

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58220 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Designator.h
lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGExprConstant.cpp
lib/CodeGen/CGExprScalar.cpp

index 6a5cff63e9047e2c3a8a8aaf6ae7b20c50eccc99..52476383aebd5bbdc08d67e892f7be4209c00523 100644 (file)
@@ -198,7 +198,7 @@ public:
   }
   
   bool hasAnyDesignators() const {
-    return Designations.empty();
+    return !Designations.empty();
   }
   
   Designation &CreateDesignation(unsigned Idx) {
index 9041c17671de4e3f2ac0986d5812e41d59d6a850..e81a64ffa552f622471498492fbd0e7b73a6d359 100644 (file)
@@ -263,7 +263,11 @@ void AggExprEmitter::VisitVAArgExpr(VAArgExpr *VE) {
 }
 
 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();
@@ -334,6 +338,11 @@ void AggExprEmitter::EmitNullInitializationToLValue(LValue LV, QualType T) {
 }
 
 void AggExprEmitter::VisitInitListExpr(InitListExpr *E) {
+  if (E->hadDesignators()) {
+    CGF.ErrorUnsupported(E, "initializer list with designators");
+    return;
+  }
+  
   // FIXME: For constant expressions, call into const expr emitter so
   // that we can emit a memcpy instead of storing the individual
   // members.  This is purely for perf; both codepaths lead to
index 5fc513d125c1f0d54407c0929e8749351b5c1c68..89b34e611ba88a70c1a6e330e91886a485ae227c 100644 (file)
@@ -315,6 +315,12 @@ public:
       const llvm::Type* RetTy = CGM.getTypes().ConvertType(ILE->getType());
       return llvm::Constant::getNullValue(RetTy);
     }
+    
+    // FIXME: We don't codegen or sema designators yet.
+    if (ILE->hadDesignators()) {
+      CGM.ErrorUnsupported(ILE, "initializer list with designators");
+      return llvm::UndefValue::get(ConvertType(ILE->getType()));
+    }
 
     if (ILE->getType()->isArrayType())
       return EmitArrayInitialization(ILE);
index 9af269eaf3507afddca0358fb289e5e034ffcf9c..2e2eea3e3105a1cab65d63b250b4c007932ceb69 100644 (file)
@@ -154,7 +154,9 @@ public:
   Value *VisitShuffleVectorExpr(ShuffleVectorExpr *E);
   Value *VisitMemberExpr(Expr *E)           { return EmitLoadOfLValue(E); }
   Value *VisitExtVectorElementExpr(Expr *E) { return EmitLoadOfLValue(E); }
-  Value *VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { return EmitLoadOfLValue(E); }
+  Value *VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
+    return EmitLoadOfLValue(E);
+  }
   Value *VisitStringLiteral(Expr *E)  { return EmitLValue(E).getAddress(); }
   Value *VisitPredefinedExpr(Expr *E) { return EmitLValue(E).getAddress(); }
 
@@ -168,6 +170,11 @@ public:
     if (!VType) 
       return Visit(E->getInit(0));
     
+    if (E->hadDesignators()) {
+      CGF.ErrorUnsupported(E, "initializer list with designators");
+      return llvm::UndefValue::get(CGF.ConvertType(E->getType()));
+    }
+    
     unsigned NumVectorElements = VType->getNumElements();
     const llvm::Type *ElementType = VType->getElementType();