aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseTentative.cpp
diff options
context:
space:
mode:
authorcor3ntin <corentinjabot@gmail.com>2024-01-27 10:23:38 +0100
committerGitHub <noreply@github.com>2024-01-27 10:23:38 +0100
commitad1a65fcacda8794e2f1fa3e1dec1c1b7813422c (patch)
treeee68f0f3f24c7dfaa09a2b75dc5427d7f11b6a15 /clang/lib/Parse/ParseTentative.cpp
parent1f13203029333ac99cc9844b8b6915aae3fc0902 (diff)
downloadllvm-ad1a65fcacda8794e2f1fa3e1dec1c1b7813422c.zip
llvm-ad1a65fcacda8794e2f1fa3e1dec1c1b7813422c.tar.gz
llvm-ad1a65fcacda8794e2f1fa3e1dec1c1b7813422c.tar.bz2
[Clang][C++26] Implement Pack Indexing (P2662R3). (#72644)
Implements https://isocpp.org/files/papers/P2662R3.pdf The feature is exposed as an extension in older language modes. Mangling is not yet supported and that is something we will have to do before release.
Diffstat (limited to 'clang/lib/Parse/ParseTentative.cpp')
-rw-r--r--clang/lib/Parse/ParseTentative.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index 5bfabf5..f1737cb 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1363,6 +1363,17 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
};
switch (Tok.getKind()) {
case tok::identifier: {
+ if (GetLookAheadToken(1).is(tok::ellipsis) &&
+ GetLookAheadToken(2).is(tok::l_square)) {
+
+ if (TryAnnotateTypeOrScopeToken())
+ return TPResult::Error;
+ if (Tok.is(tok::identifier))
+ return TPResult::False;
+ return isCXXDeclarationSpecifier(ImplicitTypenameContext::No,
+ BracedCastResult, InvalidAsDeclSpec);
+ }
+
// Check for need to substitute AltiVec __vector keyword
// for "vector" identifier.
if (TryAltiVecVectorToken())
@@ -1755,6 +1766,7 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
return TPResult::True;
}
+
[[fallthrough]];
case tok::kw_char:
@@ -1782,6 +1794,7 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
case tok::kw__Accum:
case tok::kw__Fract:
case tok::kw__Sat:
+ case tok::annot_pack_indexing_type:
#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
#include "clang/Basic/OpenCLImageTypes.def"
if (NextToken().is(tok::l_paren))
@@ -1860,6 +1873,7 @@ bool Parser::isCXXDeclarationSpecifierAType() {
switch (Tok.getKind()) {
// typename-specifier
case tok::annot_decltype:
+ case tok::annot_pack_indexing_type:
case tok::annot_template_id:
case tok::annot_typename:
case tok::kw_typeof: