Author: Younan Zhang Date: 2024-12-09T09:58:37+08:00 New Revision: a4506bb340c36d48d89afe5bd76a1a2f28f76fd9
URL: https://github.com/llvm/llvm-project/commit/a4506bb340c36d48d89afe5bd76a1a2f28f76fd9 DIFF: https://github.com/llvm/llvm-project/commit/a4506bb340c36d48d89afe5bd76a1a2f28f76fd9.diff LOG: [Clang] Recurse into parsing when using pack-indexing as a specifier (#119123) Pack indexing type that introduces a scope, e.g. `T...[0]::value` would be annotated as `annot_cxxscope`. This is something we didn't handle in `ParseCastExpression`, causing it to mistakely fall through to the logic for `raw_identifier`. We should recurse into parsing the following specifiers for such cases. Closes #119072 Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Parse/ParseExpr.cpp clang/test/Parser/cxx2c-pack-indexing.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 52b03c023b84d4..95007f357b766f 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -795,6 +795,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) - Fixed an incorrect lambda scope of generic lambdas that caused Clang to crash when computing potential lambda captures at the end of a full expression. (#GH115931) 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; +} + +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits