diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-07-09 03:07:20 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-07-09 03:07:20 +0000 |
commit | 34349003cfe040c53656d113fa344aa9e4b5d051 (patch) | |
tree | dbb747ca85e2a6cad7d4a3eda1e9e65b5c45a3be /clang/lib/Sema/SemaTemplateInstantiate.cpp | |
parent | 38b99b025ca0bb8aec13b76697417ddfaacdbfb6 (diff) | |
download | bcm5719-llvm-34349003cfe040c53656d113fa344aa9e4b5d051.tar.gz bcm5719-llvm-34349003cfe040c53656d113fa344aa9e4b5d051.zip |
PR13136:
* When substituting a reference to a non-type template parameter pack where the
corresponding argument is a pack expansion, transform into an expression
which contains an unexpanded parameter pack rather than into an expression
which contains a pack expansion. This causes the SubstNonTypeTemplateParmExpr
to be inside the PackExpansionExpr, rather than outside, so the expression
still looks like a pack expansion and can be deduced.
* Teach MarkUsedTemplateParameters that we can deduce a reference to a template
parameter if it's wrapped in a SubstNonTypeTemplateParmExpr (such nodes are
added during alias template substitution).
llvm-svn: 159922
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiate.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiate.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 7416d123017..239a0d73ebc 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -851,7 +851,7 @@ namespace { private: ExprResult transformNonTypeTemplateParmRef(NonTypeTemplateParmDecl *parm, SourceLocation loc, - const TemplateArgument &arg); + TemplateArgument arg); }; } @@ -1140,10 +1140,18 @@ TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E, ExprResult TemplateInstantiator::transformNonTypeTemplateParmRef( NonTypeTemplateParmDecl *parm, SourceLocation loc, - const TemplateArgument &arg) { + TemplateArgument arg) { ExprResult result; QualType type; + // If the argument is a pack expansion, the parameter must actually be a + // parameter pack, and we should substitute the pattern itself, producing + // an expression which contains an unexpanded parameter pack. + if (arg.isPackExpansion()) { + assert(parm->isParameterPack() && "pack expansion for non-pack"); + arg = arg.getPackExpansionPattern(); + } + // The template argument itself might be an expression, in which // case we just return that expression. if (arg.getKind() == TemplateArgument::Expression) { |