<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">[CC: key people having touched that code]</div><div class=""><br class=""></div><div class="">Dear cfe-dev,</div><div class=""><br class=""></div><div class="">I'm working on fixing <a href="https://llvm.org/PR42851" class="">https://llvm.org/PR42851</a>, a segfault that manifests when parsing a lambda with a default argument that's a lambda:</div><div class=""><br class=""></div><div class=""><font face="Monaco" class=""><span style="font-style: normal;" class="">    int main() {</span></font></div><div class=""><font face="Monaco" class=""><span style="font-style: normal;" class="">        auto apply = [](auto, void(*)() = []{}) { };</span></font></div><div class=""><font face="Monaco" class=""><span style="font-style: normal;" class="">        apply(1); //                      ^^^^ BOOM</span></font></div><div class=""><font face="Monaco" class=""><span style="font-style: normal;" class="">    }</span></font></div><div class=""><br class=""></div><div class="">Long story short, what's happening is that when we parse the parameter-declaration-clause of the lambda, we don't record that we're in a dependent context, i.e. that we're basically parsing a template for the closure type's operator(). We don't know that we're in a template until we actually hit the first parameter declared with 'auto', but by then we've already done some things wrong (e.g. we've injected declarations into a parse scope that is not marked as being a template).</div><div class=""><br class=""></div><div class="">So what I've come to believe is that we should "tentatively parse" the parameter-declaration-clause of the lambda and try to determine whether it's going to be a generic lambda before we actually go ahead and parse it "for real", with a parse scope that's correctly marked as being dependent (or not). However, we must do that tentative parsing without calling into Sema, because calling into Sema has side effects that we can't undo easily. This means I can't reuse most of the existing machinery for parsing a parameter-declaration-clause.</div><div class=""><br class=""></div><div class="">I found TentativeParsingAction and I'm aware of a few tentative parsing functions in ParseTentative.cpp (like TryParseParameterDeclarationClause, which doesn't do quite what I need). However, before I invest any more time down that path, I'd like to know whether others think I'm going down the right path.</div><div class=""><br class=""></div><div class="">Any insights welcome,</div><div class="">Louis</div><div class=""><br class=""></div></body></html>