diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-10-26 23:53:12 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-10-26 23:53:12 +0000 |
| commit | 084bc32e0d0c80216a85597f1d08d67386099c58 (patch) | |
| tree | 970f0834e4becac6386b441d756be218c20b2da8 /clang/lib/CodeGen | |
| parent | 07d754acf11590af580bcc4b8816105a60ebb8fe (diff) | |
| download | bcm5719-llvm-084bc32e0d0c80216a85597f1d08d67386099c58.tar.gz bcm5719-llvm-084bc32e0d0c80216a85597f1d08d67386099c58.zip | |
make codegen reject initializes with designators, like this:
t.c:1:13: error: cannot codegen this designators yet
int a[10] = {2, 4, [8]=9, 10};
^~~~~~~~~~~~~~~~~
llvm-svn: 58220
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGExprAgg.cpp | 11 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 9 |
3 files changed, 24 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index 9041c17671d..e81a64ffa55 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -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 diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 5fc513d125c..89b34e611ba 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -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); diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 9af269eaf35..2e2eea3e310 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -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(); |

