[clang] [Clang] fix crash with generic lambdas in function default args (PR #222987)

Oleksandr Tarasiuk via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 25 02:23:04 PDT 2026


================
@@ -7756,6 +7756,12 @@ void Parser::ParseParameterDeclarationClause(
           DelayTemplateIdDestructionRAII DontDestructTemplateIds(
               *this, /*DelayTemplateIdDestruction=*/true);
 
+          TemplateParameterDepthRAII CurTemplateDepthTracker(
+              TemplateParameterDepth);
+          unsigned Depth = Actions.getTemplateDepth(getCurScope());
+          if (Depth > TemplateParameterDepth)
+            CurTemplateDepthTracker.addDepth(Depth - TemplateParameterDepth);
----------------
a-tarasyuk wrote:

I reworked this to track the implicit template scope directly and use `getInventedTemplateParameterList` when re-entering it. I also added tests for deduced lambda types and non-type parameters. Defaults before the first `auto` are still outside the scope of this fix... 

https://github.com/llvm/llvm-project/pull/222987


More information about the cfe-commits mailing list