diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiate.cpp | 24 |
2 files changed, 24 insertions, 3 deletions
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 38a6919be3..3afa4ee6b2 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -488,6 +488,9 @@ static void InitializePredefinedMacros(Preprocessor &PP, else if (0) // STDC94 ? DefineBuiltinMacro(Buf, "__STDC_VERSION__=199409L"); + if (PP.getLangOptions().CPlusPlus0x) + DefineBuiltinMacro(Buf, "__GXX_EXPERIMENTAL_CXX0X__"); + if (PP.getLangOptions().Freestanding) DefineBuiltinMacro(Buf, "__STDC_HOSTED__=0"); else diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp index b7f0bbc923..dbdc5a8a71 100644 --- a/lib/Sema/SemaTemplateInstantiate.cpp +++ b/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 |