diff options
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index f35d1aa..aff2d1c 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2094,14 +2094,13 @@ static void collectUnexpandedParameterPacks( Sema &S, TemplateParameterList *Params, SmallVectorImpl<UnexpandedParameterPack> &Unexpanded) { - for (TemplateParameterList::const_iterator I = Params->begin(), - E = Params->end(); I != E; ++I) { - if ((*I)->isTemplateParameterPack()) + for (const auto &P : *Params) { + if (P->isTemplateParameterPack()) continue; - if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*I)) + if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P)) S.collectUnexpandedParameterPacks(NTTP->getTypeSourceInfo()->getTypeLoc(), Unexpanded); - if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(*I)) + if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(P)) collectUnexpandedParameterPacks(S, TTP->getTemplateParameters(), Unexpanded); } @@ -2731,9 +2730,8 @@ TemplateDeclInstantiator::SubstTemplateParams(TemplateParameterList *L) { typedef SmallVector<NamedDecl *, 8> ParamVector; ParamVector Params; Params.reserve(N); - for (TemplateParameterList::iterator PI = L->begin(), PE = L->end(); - PI != PE; ++PI) { - NamedDecl *D = cast_or_null<NamedDecl>(Visit(*PI)); + for (auto &P : *L) { + NamedDecl *D = cast_or_null<NamedDecl>(Visit(P)); Params.push_back(D); Invalid = Invalid || !D || D->isInvalidDecl(); } @@ -3246,10 +3244,18 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New, // DR1330: In C++11, defer instantiation of a non-trivial // exception specification. + // DR1484: Local classes and their members are instantiated along with the + // containing function. + bool RequireInstantiation = false; + if (CXXRecordDecl *Cls = dyn_cast<CXXRecordDecl>(Tmpl->getDeclContext())) { + if (Cls->isLocalClass()) + RequireInstantiation = true; + } if (SemaRef.getLangOpts().CPlusPlus11 && EPI.ExceptionSpec.Type != EST_None && EPI.ExceptionSpec.Type != EST_DynamicNone && - EPI.ExceptionSpec.Type != EST_BasicNoexcept) { + EPI.ExceptionSpec.Type != EST_BasicNoexcept && + !RequireInstantiation) { FunctionDecl *ExceptionSpecTemplate = Tmpl; if (EPI.ExceptionSpec.Type == EST_Uninstantiated) ExceptionSpecTemplate = EPI.ExceptionSpec.SourceTemplate; |