[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
This commit is contained in:
Younan Zhang 2024-12-09 09:58:37 +08:00 committed by GitHub
parent 712264b83c
commit a4506bb340
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View File

@ -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)

View File

@ -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);
}

View File

@ -74,3 +74,12 @@ struct SS {
}
};
}
namespace GH119072 {
template<typename... Ts>
void foo() {
decltype(Ts...[0]::t) value;
}
}