[Clang] Fix parsing of pack-index-specifier with template-id pattern#3
[Clang] Fix parsing of pack-index-specifier with template-id pattern#3sdkrystian wants to merge 2 commits intocppalliance:mainfrom
Conversation
17c8a8b to
b7e5531
Compare
b7e5531 to
5b04344
Compare
| getCurScope(), ElaboratedTypeKeyword::None, | ||
| /*ElaboratedKeywordLoc=*/SourceLocation(), SS, | ||
| TemplateId->TemplateKWLoc, TemplateId->Template, | ||
| TemplateId->Name, TemplateId->TemplateNameLoc, | ||
| TemplateId->LAngleLoc, TemplateArgsPtr, TemplateId->RAngleLoc, | ||
| /*IsCtorOrDtorName=*/false, /*IsClassName=*/false, | ||
| ImplicitTypenameContext::No); |
There was a problem hiding this comment.
This needs rewiring for nested name and elaborated keyword support, with additional tests covering those cases.
AST dump tests and ast-print roundtrip tests would make good confirmation this works.
Endilll
left a comment
There was a problem hiding this comment.
-
I see that pack indexing is handled before the loop in
ParseOptionalCXXScopeSpecifier, too:clang/clang/lib/Parse/ParseExprCXX.cpp
Line 194 in b94c5e0
I'm not sure we need to touch it, but would be nice if description touched on that -
Would be nice to mention somewhere that previously only the
identifierform oftypedef-namewithinpack-index-specifierwas handled, but this PR handlessimple-template-idform oftypedef-name. -
"template-id" in the title mislead me to believe that this is covering not just
simple-template-id, but alsooperator-function-id < template-argument-list (opt)>andliteral-operator-id < template-argument-list (opt) >. This is not the case, and it would be nice to have couple more tests that make sure those forms oftemplate-idare not accepted withinpack-index-specifier.
Previously,
ParseOptionalCXXScopeSpecifieronly handled pack-index-specifiers where the pattern was a simple identifier (e.g.,T...[0]::). This patch adds support fortemplate-idpatterns (e.g.,Foo<T>...[0]::).The fix involves two parts:
ParsePackIndexingTypeto handletok::annot_template_idin addition totok::identifier.ParseOptionalCXXScopeSpecifierforannot_template_idfollowed by... [ constant-expression ].This fixes code like:
which previously failed to parse.