summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaTemplateDeduction.cpp
diff options
context:
space:
mode:
authorFaisal Vali <faisalv@yahoo.com>2014-06-01 16:11:54 +0000
committerFaisal Vali <faisalv@yahoo.com>2014-06-01 16:11:54 +0000
commit4f1b413f41afb3833bc5f645c212873f8132fe74 (patch)
tree27a18ec4b33d49703f6ec36a1f4db9a6db0f0657 /lib/Sema/SemaTemplateDeduction.cpp
parent835addee1e863247210437421dde8c879342ba81 (diff)
Fix PR18498: Support explicit template arguments with variadic generic lambdas
http://llvm.org/bugs/show_bug.cgi?id=18498 This code was resulting in a crash: auto L = [](auto ... v) { }; L.operator()<int>(3); The reason is that the partially-substituted-pack is incorrectly retained within the current-instantiation-scope during template-argument-finalization, and because lambda's are local, there parent instantiation scopes are merged, which leads to the expansion-pattern being retained in the finalized specialization. This patch ensures that once we have finalized deduction of a parameter-pack, we remove the partially-substituted-pack so that it doesn't cause CheckParameterPacksForExpansion to incorrectly inform the caller that it needs to retain the expansion pattern. Thanks to Richard Smith for the review! http://reviews.llvm.org/D2135 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209992 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index 7d9cec141a..f941a0992c 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -2816,9 +2816,19 @@ Sema::FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
// argument, because it was explicitly-specified. Just record the
// presence of this argument.
Builder.push_back(Deduced[I]);
+ // We may have had explicitly-specified template arguments for a
+ // template parameter pack (that may or may not have been extended
+ // via additional deduced arguments).
+ if (Param->isParameterPack() && CurrentInstantiationScope) {
+ if (CurrentInstantiationScope->getPartiallySubstitutedPack() ==
+ Param) {
+ // Forget the partially-substituted pack; its substitution is now
+ // complete.
+ CurrentInstantiationScope->ResetPartiallySubstitutedPack();
+ }
+ }
continue;
}
-
// We have deduced this argument, so it still needs to be
// checked and converted.