From fbbb8c17f50e6bb450a12965d30ac47a12c9aa58 Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Tue, 24 Oct 2017 01:39:56 +0000 Subject: [PATCH] Fix template parameter default args missed if redecled This bug was found via self-build on lld, and worked around here: https://reviews.llvm.org/rL316180 The issue is that the 'using' causes the lookup to pick up the first decl. However, when setting inherited default parameters, we only update 'forward', not 'backward'. SO, only the newest param list has all the information about the default arguments. This patch ensures that the list of parameters we look through checks the newest decl's template parameter list so it doesn't miss a default. Differential Revision: https://reviews.llvm.org/D39127 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316405 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaTemplate.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 0930fdd653..26b80f11fb 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -4805,7 +4805,12 @@ bool Sema::CheckTemplateArgumentList( // template. TemplateArgumentListInfo NewArgs = TemplateArgs; - TemplateParameterList *Params = Template->getTemplateParameters(); + // Make sure we get the template parameter list from the most + // recentdeclaration, since that is the only one that has is guaranteed to + // have all the default template argument information. + TemplateParameterList *Params = + cast(Template->getMostRecentDecl()) + ->getTemplateParameters(); SourceLocation RAngleLoc = NewArgs.getRAngleLoc(); -- 2.50.1