[cfe-commits] r131211 - in /cfe/trunk: lib/Sema/SemaTemplate.cpp test/SemaCXX/PR9902.cpp

Douglas Gregor dgregor at apple.com
Thu May 12 08:54:58 PDT 2011


On May 11, 2011, at 5:06 PM, Richard Smith wrote:

> Author: rsmith
> Date: Wed May 11 19:06:17 2011
> New Revision: 131211
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=131211&view=rev
> Log:
> Fix PR9902: correctly substitute alias templates within the template in which they are defined: provide an empty list of arguments for each containing template context during substitution.
> 
> 
> Added:
>    cfe/trunk/test/SemaCXX/PR9902.cpp
> 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=131211&r1=131210&r2=131211&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed May 11 19:06:17 2011
> @@ -1855,6 +1855,9 @@
> 
>     // Only substitute for the innermost template argument list.
>     MultiLevelTemplateArgumentList TemplateArgLists;
> +    unsigned Depth = AliasTemplate->getTemplateParameters()->getDepth();
> +    for (unsigned I = 0; I < Depth; ++I)
> +      TemplateArgLists.addOuterTemplateArguments(0, 0);
>     TemplateArgLists.addOuterTemplateArguments(&TemplateArgs);


Sure, this makes sense. And we've already made substitution robust against template parameters that don't exist because we need that for explicitly-specified function templates arguments. Nice fix!

	- Doug



More information about the cfe-commits mailing list