This is an archive of the discontinued LLVM Phabricator instance.

Support explicit template arguments with variadic generic lambdas
ClosedPublic

Authored by faisalv on Nov 10 2013, 6:56 PM.

Details

Summary

Currently clang-trunk crashes on the following:

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!

Diff Detail

Event Timeline

rsmith accepted this revision.Jan 16 2014, 12:53 PM

LGTM with a simplification.

lib/Sema/SemaTemplateDeduction.cpp
2807–2810

You don't need to pass these unused pointer args. Just:

if (Param->isParameterPack() && CurrentInstantiationScope &&
    CurrentInstantiationScope->getPartiallySubstitutedPack() == Param)
  CurrentInstantiationScope->ResetPartiallySubstitutedPack();

... should do the trick.