Skip to content

Commit a4506bb

Browse files
authored
[Clang] Recurse into parsing when using pack-indexing as a specifier (llvm#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 llvm#119072
1 parent 712264b commit a4506bb

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,7 @@ Bug Fixes to C++ Support
795795
- Fixed a bug where bounds of partially expanded pack indexing expressions were checked too early. (#GH116105)
796796
- Fixed an assertion failure caused by using ``consteval`` in condition in consumed analyses. (#GH117385)
797797
- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659)
798+
- Fixed a parser crash when using pack indexing as a nested name specifier. (#GH119072)
798799
- Fixed an assertion failure caused by mangled names with invalid identifiers. (#GH112205)
799800
- Fixed an incorrect lambda scope of generic lambdas that caused Clang to crash when computing potential lambda
800801
captures at the end of a full expression. (#GH115931)

clang/lib/Parse/ParseExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
11991199
// If the token is not annotated, then it might be an expression pack
12001200
// indexing
12011201
if (!TryAnnotateTypeOrScopeToken() &&
1202-
Tok.is(tok::annot_pack_indexing_type))
1202+
Tok.isOneOf(tok::annot_pack_indexing_type, tok::annot_cxxscope))
12031203
return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
12041204
isVectorLiteral, NotPrimaryExpression);
12051205
}

clang/test/Parser/cxx2c-pack-indexing.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,12 @@ struct SS {
7474
}
7575
};
7676
}
77+
78+
namespace GH119072 {
79+
80+
template<typename... Ts>
81+
void foo() {
82+
decltype(Ts...[0]::t) value;
83+
}
84+
85+
}

0 commit comments

Comments
 (0)