summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-01-28 21:54:33 +0000
committerDouglas Gregor <dgregor@apple.com>2009-01-28 21:54:33 +0000
commit347f7eabb9ae43482f04855cde43f9d164b7b6f0 (patch)
treeb167e4bf7fc08a2d9c09efd46cb7775daed2b521 /clang/lib/Sema/SemaDecl.cpp
parentc78320960513fe9f193104cbb07b0a5711c81ee0 (diff)
downloadbcm5719-llvm-347f7eabb9ae43482f04855cde43f9d164b7b6f0.tar.gz
bcm5719-llvm-347f7eabb9ae43482f04855cde43f9d164b7b6f0.zip
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) llvm-svn: 63242
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index cfbd288aaea..79efc7df9c0 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1136,6 +1136,9 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
}
InitListChecker CheckInitList(this, InitList, DeclType);
+ if (!CheckInitList.HadError())
+ Init = CheckInitList.getFullyStructuredList();
+
return CheckInitList.HadError();
}
@@ -2209,6 +2212,12 @@ bool Sema::CheckForConstantInitializer(Expr *Init, QualType DclT) {
for (unsigned i = 0; i < numInits; i++) {
// FIXME: Need to get the type of the declaration for C++,
// because it could be a reference?
+
+ // Implicitly-generated value initializations are okay.
+ if (isa<CXXZeroInitValueExpr>(Exp->getInit(i)) &&
+ cast<CXXZeroInitValueExpr>(Exp->getInit(i))->isImplicit())
+ continue;
+
if (CheckForConstantInitializer(Exp->getInit(i),
Exp->getInit(i)->getType()))
return true;
OpenPOWER on IntegriCloud