r316405 - Fix template parameter default args missed if redecled
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 23 18:39:56 PDT 2017
Author: erichkeane
Date: Mon Oct 23 18:39:56 2017
New Revision: 316405
URL: http://llvm.org/viewvc/llvm-project?rev=316405&view=rev
Log:
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
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=316405&r1=316404&r2=316405&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Oct 23 18:39:56 2017
@@ -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<TemplateDecl>(Template->getMostRecentDecl())
+ ->getTemplateParameters();
SourceLocation RAngleLoc = NewArgs.getRAngleLoc();
More information about the cfe-commits
mailing list