summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateDeduction.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-07-09 03:07:20 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-07-09 03:07:20 +0000
commit34349003cfe040c53656d113fa344aa9e4b5d051 (patch)
treedbb747ca85e2a6cad7d4a3eda1e9e65b5c45a3be /clang/lib/Sema/SemaTemplateDeduction.cpp
parent38b99b025ca0bb8aec13b76697417ddfaacdbfb6 (diff)
downloadbcm5719-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/SemaTemplateDeduction.cpp')
-rw-r--r--clang/lib/Sema/SemaTemplateDeduction.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index b8ec59ee1d6..60f5bc196e0 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4166,9 +4166,17 @@ MarkUsedTemplateParameters(ASTContext &Ctx,
if (const PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(E))
E = Expansion->getPattern();
- // Skip through any implicit casts we added while type-checking.
- while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
- E = ICE->getSubExpr();
+ // Skip through any implicit casts we added while type-checking, and any
+ // substitutions performed by template alias expansion.
+ while (1) {
+ if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
+ E = ICE->getSubExpr();
+ else if (const SubstNonTypeTemplateParmExpr *Subst =
+ dyn_cast<SubstNonTypeTemplateParmExpr>(E))
+ E = Subst->getReplacement();
+ else
+ break;
+ }
// FIXME: if !OnlyDeduced, we have to walk the whole subexpression to
// find other occurrences of template parameters.
OpenPOWER on IntegriCloud