diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-01-28 21:54:33 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-01-28 21:54:33 +0000 |
commit | 4c67834407ca6ab344dcf44fc599ad4938cfa96d (patch) | |
tree | d7d3838ffe094efc25517516290d26e484e2ca26 /lib/CodeGen/CGExprConstant.cpp | |
parent | abf439731bc4f56df2df9e54d6c242e2c633f5ca (diff) |
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
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 32d126e590..3b6ebb4d56 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -242,6 +242,8 @@ public: const llvm::Type *Ty = ConvertType(ILE->getType()); // Find the field decl we're initializing, if any + // FIXME: C99 designated initializers won't always initialize the + // first field int FieldNo = 0; // Field no in RecordDecl FieldDecl* curField = 0; for (RecordDecl::field_iterator Field = RD->field_begin(), @@ -304,12 +306,6 @@ public: 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); |