[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 14 06:57:27 PDT 2024


================
@@ -738,16 +738,47 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration(
       return nullptr;
     }
 
-    if (!Tok.is(tok::identifier)) {
+    Decl *UED = nullptr;
+
+    if (Tok.is(tok::identifier)) {
----------------
Endilll wrote:

1) You're correct that `ParseOptionalCXXScopeSpecifier` is going to provide us a `TemplateIdAnnotation` every time there is an identifier followed by a "less than" sign.

2) On top of what I do here, `ParseBaseTypeSpecifier` handles `computed-type-specifier` (which is `decltype` and pack indexing) and dependent types. If you take a look at which tokens that function expects, they are `tok::kw_decltype`, `tok::annot_decltype`, `tok::annot_pack_indexing_type`, `tok::annot_template_id`, and `tok::identifier`. If we remove tokens that are coming from `computed-type-specifier`, we'll be left with just `tok::annot_template_id` and `tok::identifier`, which are exactly the tokens I expect.

> Line 723, ParseOptionalCXXScopeSpecifier, there are options to make it a type only context for error recovery

I'd be wary to mark this as a type-only context, unless the Standard says so. I believe it doesn't for `using enum`, but does for base specifier, because the latter uses `class-or-decltype` grammar.

https://github.com/llvm/llvm-project/pull/95399


More information about the cfe-commits mailing list