@@ -1824,6 +1824,15 @@ static void SetNestedNameSpecifier(Sema &S, TagDecl *T,
18241824 T->setQualifierInfo (SS.getWithLocInContext (S.Context ));
18251825}
18261826
1827+ // Returns the template parameter list with all default template argument
1828+ // information.
1829+ static TemplateParameterList *GetTemplateParameterList (TemplateDecl *TD) {
1830+ // Make sure we get the template parameter list from the most
1831+ // recent declaration, since that is the only one that is guaranteed to
1832+ // have all the default template argument information.
1833+ return cast<TemplateDecl>(TD->getMostRecentDecl ())->getTemplateParameters ();
1834+ }
1835+
18271836DeclResult Sema::CheckClassTemplate (
18281837 Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
18291838 CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
@@ -2061,13 +2070,13 @@ DeclResult Sema::CheckClassTemplate(
20612070 if (!(TUK == TUK_Friend && CurContext->isDependentContext ()) &&
20622071 CheckTemplateParameterList (
20632072 TemplateParams,
2064- PrevClassTemplate
2065- ? PrevClassTemplate->getMostRecentDecl ()->getTemplateParameters ()
2066- : nullptr ,
2073+ PrevClassTemplate ? GetTemplateParameterList (PrevClassTemplate)
2074+ : nullptr ,
20672075 (SS.isSet () && SemanticContext && SemanticContext->isRecord () &&
20682076 SemanticContext->isDependentContext ())
20692077 ? TPC_ClassTemplateMember
2070- : TUK == TUK_Friend ? TPC_FriendClassTemplate : TPC_ClassTemplate,
2078+ : TUK == TUK_Friend ? TPC_FriendClassTemplate
2079+ : TPC_ClassTemplate,
20712080 SkipBody))
20722081 Invalid = true ;
20732082
@@ -2298,7 +2307,7 @@ struct ConvertConstructorToDeductionGuideTransform {
22982307 // -- The template parameters are the template parameters of the class
22992308 // template followed by the template parameters (including default
23002309 // template arguments) of the constructor, if any.
2301- TemplateParameterList *TemplateParams = Template-> getTemplateParameters ( );
2310+ TemplateParameterList *TemplateParams = GetTemplateParameterList (Template );
23022311 if (FTD) {
23032312 TemplateParameterList *InnerParams = FTD->getTemplateParameters ();
23042313 SmallVector<NamedDecl *, 16 > AllParams;
@@ -2424,7 +2433,7 @@ struct ConvertConstructorToDeductionGuideTransform {
24242433 Params.push_back (NewParam);
24252434 }
24262435
2427- return buildDeductionGuide (Template-> getTemplateParameters ( ), nullptr ,
2436+ return buildDeductionGuide (GetTemplateParameterList (Template ), nullptr ,
24282437 ExplicitSpecifier (), TSI, Loc, Loc, Loc);
24292438 }
24302439
@@ -5956,12 +5965,7 @@ bool Sema::CheckTemplateArgumentList(
59565965 // template.
59575966 TemplateArgumentListInfo NewArgs = TemplateArgs;
59585967
5959- // Make sure we get the template parameter list from the most
5960- // recent declaration, since that is the only one that is guaranteed to
5961- // have all the default template argument information.
5962- TemplateParameterList *Params =
5963- cast<TemplateDecl>(Template->getMostRecentDecl ())
5964- ->getTemplateParameters ();
5968+ TemplateParameterList *Params = GetTemplateParameterList (Template);
59655969
59665970 SourceLocation RAngleLoc = NewArgs.getRAngleLoc ();
59675971
0 commit comments