[cfe-commits] r58220 - in /cfe/trunk: include/clang/Parse/Designator.h lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CGExprConstant.cpp lib/CodeGen/CGExprScalar.cpp
Chris Lattner
sabre at nondot.org
Sun Oct 26 16:53:12 PDT 2008
Author: lattner
Date: Sun Oct 26 18:53:12 2008
New Revision: 58220
URL: http://llvm.org/viewvc/llvm-project?rev=58220&view=rev
Log:
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};
^~~~~~~~~~~~~~~~~
Modified:
cfe/trunk/include/clang/Parse/Designator.h
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
Modified: cfe/trunk/include/clang/Parse/Designator.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Designator.h?rev=58220&r1=58219&r2=58220&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Designator.h (original)
+++ cfe/trunk/include/clang/Parse/Designator.h Sun Oct 26 18:53:12 2008
@@ -198,7 +198,7 @@
}
bool hasAnyDesignators() const {
- return Designations.empty();
+ return !Designations.empty();
}
Designation &CreateDesignation(unsigned Idx) {
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=58220&r1=58219&r2=58220&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Sun Oct 26 18:53:12 2008
@@ -263,7 +263,11 @@
}
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::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
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=58220&r1=58219&r2=58220&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Sun Oct 26 18:53:12 2008
@@ -315,6 +315,12 @@
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);
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=58220&r1=58219&r2=58220&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sun Oct 26 18:53:12 2008
@@ -154,7 +154,9 @@
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 @@
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();
More information about the cfe-commits
mailing list