From 3628cb9cb67bf934a8a01a1bb619f25ce8188c4c Mon Sep 17 00:00:00 2001 From: Faisal Vali Date: Sun, 1 Jun 2014 16:11:54 +0000 Subject: 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()(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 llvm-svn: 209992 --- clang/lib/Sema/SemaTemplateDeduction.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'clang/lib') diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 7d9cec141a3..f941a0992cb 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/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. -- cgit v1.2.3