aboutsummaryrefslogtreecommitdiff
path: root/CodeGen/CGExprConstant.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-01-29 01:15:48 +0000
committerAnders Carlsson <andersca@mac.com>2008-01-29 01:15:48 +0000
commitf6884ac7cfc4c5562c0678ad65b3460a38f56e23 (patch)
tree6bf6cb0df06894c5a37b8c41027105fecddc0b64 /CodeGen/CGExprConstant.cpp
parentff6e3c596e38328447461894cb8fd3ae22f499c4 (diff)
Correctly handle scalars in braces.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46480 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CGExprConstant.cpp')
-rw-r--r--CodeGen/CGExprConstant.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/CodeGen/CGExprConstant.cpp b/CodeGen/CGExprConstant.cpp
index 5808da4212..da2fef66f0 100644
--- a/CodeGen/CGExprConstant.cpp
+++ b/CodeGen/CGExprConstant.cpp
@@ -68,26 +68,18 @@ public:
}
llvm::Constant *VisitInitListExpr(InitListExpr *ILE) {
- if (ILE->getType()->isVoidType()) {
- // FIXME: Remove this when sema of initializers is finished (and the code
- // below).
- CGM.WarnUnsupported(ILE, "initializer");
- return 0;
+ const llvm::CompositeType *CType =
+ dyn_cast<llvm::CompositeType>(ConvertType(ILE->getType()));
+
+ if (!CType) {
+ // We have a scalar in braces. Just use the first element.
+ return Visit(ILE->getInit(0));
}
-
- assert((ILE->getType()->isArrayType() || ILE->getType()->isStructureType() ||
- ILE->getType()->isVectorType()) &&
- "Bad type for init list!");
- CodeGenTypes& Types = CGM.getTypes();
-
+
unsigned NumInitElements = ILE->getNumInits();
unsigned NumInitableElts = NumInitElements;
-
- const llvm::CompositeType *CType =
- cast<llvm::CompositeType>(Types.ConvertType(ILE->getType()));
- assert(CType);
std::vector<llvm::Constant*> Elts;
-
+
// Initialising an array requires us to automatically initialise any
// elements that have not been initialised explicitly
const llvm::ArrayType *AType = 0;