[clang] [Clang] Recurse into parsing when using pack-indexing as a specifier (PR #119123)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 8 02:22:08 PST 2024
https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/119123
Closes #119072
>From 7ea2b4c5a9042aeb77982e3f5bb03af36de23c96 Mon Sep 17 00:00:00 2001
From: Younan Zhang <zyn7109 at gmail.com>
Date: Sun, 8 Dec 2024 18:17:46 +0800
Subject: [PATCH] [Clang] Recurse into parsing when using pack-indexing as a
specifier
---
clang/docs/ReleaseNotes.rst | 1 +
clang/lib/Parse/ParseExpr.cpp | 2 +-
clang/test/Parser/cxx2c-pack-indexing.cpp | 9 +++++++++
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 20bd27ad52f577..57fcca04fc53ca 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -763,6 +763,7 @@ Bug Fixes to C++ Support
- Fixed a bug where bounds of partially expanded pack indexing expressions were checked too early. (#GH116105)
- Fixed an assertion failure caused by using ``consteval`` in condition in consumed analyses. (#GH117385)
- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659)
+- Fixed a parser crash when using pack indexing as a nested name specifier. (#GH119072)
- Fixed an assertion failure caused by mangled names with invalid identifiers. (#GH112205)
Bug Fixes to AST Handling
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 736484ded8383c..8dd72db8f5b4a2 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1199,7 +1199,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
// If the token is not annotated, then it might be an expression pack
// indexing
if (!TryAnnotateTypeOrScopeToken() &&
- Tok.is(tok::annot_pack_indexing_type))
+ Tok.isOneOf(tok::annot_pack_indexing_type, tok::annot_cxxscope))
return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
isVectorLiteral, NotPrimaryExpression);
}
diff --git a/clang/test/Parser/cxx2c-pack-indexing.cpp b/clang/test/Parser/cxx2c-pack-indexing.cpp
index c279bdd7af8c44..99347a2f8f1571 100644
--- a/clang/test/Parser/cxx2c-pack-indexing.cpp
+++ b/clang/test/Parser/cxx2c-pack-indexing.cpp
@@ -74,3 +74,12 @@ struct SS {
}
};
}
+
+namespace GH119072 {
+
+template<typename... Ts>
+void foo() {
+ decltype(Ts...[0]::t) value;
+}
+
+}
More information about the cfe-commits
mailing list