[clang] [Clang] Fix a crash when forming a type from an indexed TTP. (PR #222326)

via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 9 06:02:49 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Corentin Jabot (cor3ntin)

<details>
<summary>Changes</summary>

Unreported 24 issue so no release note.

---
Full diff: https://github.com/llvm/llvm-project/pull/222326.diff


2 Files Affected:

- (modified) clang/lib/Parse/ParseExpr.cpp (+1-1) 
- (modified) clang/test/SemaCXX/cxx2d-pack-indexing-template.cpp (+12) 


``````````diff
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 8f212fab4cdbf..d9d97bcbdbb21 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -905,7 +905,7 @@ Parser::ParseCastExpression(CastParseKind ParseKind, bool isAddressOfOperand,
         if (TryAnnotateTypeOrScopeToken())
           return ExprError();
         if (Tok.isOneOf(tok::annot_cxxscope, tok::annot_pack_indexing_type,
-                        tok::annot_template_id))
+                        tok::annot_template_id, tok::annot_typename))
           return ParseCastExpression(ParseKind, isAddressOfOperand,
                                      CorrectionBehavior, isVectorLiteral,
                                      NotPrimaryExpression);
diff --git a/clang/test/SemaCXX/cxx2d-pack-indexing-template.cpp b/clang/test/SemaCXX/cxx2d-pack-indexing-template.cpp
index 0298be66b1a86..f1d9b1b8ce3d0 100644
--- a/clang/test/SemaCXX/cxx2d-pack-indexing-template.cpp
+++ b/clang/test/SemaCXX/cxx2d-pack-indexing-template.cpp
@@ -105,6 +105,18 @@ auto ctad() {
   return x;
 }
 static_assert(__is_same(decltype(ctad<Deduce>()), Deduce<int>));
+
+template <template <class> class... TT>
+auto ctad_paren() {
+  return TT...[0](42);
+}
+static_assert(__is_same(decltype(ctad_paren<Deduce>()), Deduce<int>));
+
+template <template <class> class... TT>
+auto ctad_braced() {
+  return TT...[1]{42};
+}
+static_assert(__is_same(decltype(ctad_braced<A, Deduce>()), Deduce<int>));
 }
 
 namespace deduction_guides {

``````````

</details>


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


More information about the cfe-commits mailing list