summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-03-15 20:12:13 +0000
committerAnders Carlsson <andersca@mac.com>2009-03-15 20:12:13 +0000
commit5bd30395b96ce7ab3e5495a2af5639c3b29669ea (patch)
treeb9c498f9379c40dfa47b3ad7434f971ee6a6fde2 /clang/lib/Sema
parent27de6a5e9148f3090fdf4e70c50a9238e60d11d0 (diff)
downloadbcm5719-llvm-5bd30395b96ce7ab3e5495a2af5639c3b29669ea.tar.gz
bcm5719-llvm-5bd30395b96ce7ab3e5495a2af5639c3b29669ea.zip
(Hopefully) instantiate dependent array types correctly.
llvm-svn: 67032
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaTemplateInstantiate.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index b7f0bbc923a..dbdc5a8a716 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -283,9 +283,27 @@ QualType
TemplateTypeInstantiator::
InstantiateDependentSizedArrayType(const DependentSizedArrayType *T,
unsigned Quals) const {
- // FIXME: Implement this
- assert(false && "Cannot instantiate DependentSizedArrayType yet");
- return QualType();
+ Expr *ArraySize = T->getSizeExpr();
+ assert(ArraySize->isValueDependent() &&
+ "dependent sized array types must have value dependent size expr");
+
+ // Instantiate the element type if needed
+ QualType ElementType = T->getElementType();
+ if (ElementType->isDependentType()) {
+ ElementType = Instantiate(ElementType);
+ if (ElementType.isNull())
+ return QualType();
+ }
+
+ // Instantiate the size expression
+ Sema::OwningExprResult InstantiatedArraySize =
+ SemaRef.InstantiateExpr(ArraySize, TemplateArgs, NumTemplateArgs);
+ if (InstantiatedArraySize.isInvalid())
+ return QualType();
+
+ return SemaRef.BuildArrayType(ElementType, T->getSizeModifier(),
+ (Expr *)InstantiatedArraySize.release(),
+ T->getIndexTypeQualifier(), Loc, Entity);
}
QualType
OpenPOWER on IntegriCloud