[clang] [Clang] Fix a crash when forming a type from an indexed TTP. (PR #222326)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 9 06:02:10 PDT 2026
https://github.com/cor3ntin created https://github.com/llvm/llvm-project/pull/222326
Unreported 24 issue so no release note.
>From 777ba802a0b9f60e4a77ba07d2f16a9c121e0003 Mon Sep 17 00:00:00 2001
From: Corentin Jabot <corentinjabot at gmail.com>
Date: Wed, 9 Sep 2026 14:59:54 +0200
Subject: [PATCH] [Clang] Fix a crash when forming a type from an indexed TTP.
Unreported 24 issue so no release note.
---
clang/lib/Parse/ParseExpr.cpp | 2 +-
clang/test/SemaCXX/cxx2d-pack-indexing-template.cpp | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
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 {
More information about the cfe-commits
mailing list