[clang] [clang] Implement CWG2877 "Type-only lookup for using-enum-declarator" (PR #95399)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 13 05:24:46 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)) {
+ IdentifierInfo *IdentInfo = Tok.getIdentifierInfo();
+ SourceLocation IdentLoc = ConsumeToken();
+
+ ParsedType Type = Actions.getTypeName(
+ *IdentInfo, IdentLoc, getCurScope(), &SS, /*isClassName=*/true,
+ /*HasTrailingDot=*/false,
+ /*ObjectType=*/nullptr, /*IsCtorOrDtorName=*/false,
+ /*WantNontrivialTypeSourceInfo=*/true);
+
+ UED = Actions.ActOnUsingEnumDeclaration(
+ getCurScope(), AS, UsingLoc, UELoc, IdentLoc, *IdentInfo, Type, &SS);
+ } else if (Tok.is(tok::annot_template_id)) {
+ TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
+
+ if (TemplateId->mightBeType()) {
+ AnnotateTemplateIdTokenAsType(SS, ImplicitTypenameContext::No,
+ /*IsClassName=*/true);
+
+ assert(Tok.is(tok::annot_typename) && "template-id -> type failed");
+ TypeResult Type = getTypeAnnotation(Tok);
+ SourceRange Loc = Tok.getAnnotationRange();
+ ConsumeAnnotationToken();
+
+ UED = Actions.ActOnUsingEnumDeclaration(getCurScope(), AS, UsingLoc,
+ UELoc, Loc, *TemplateId->Name,
+ Type.get(), &SS);
+ } else {
+ Diag(Tok.getLocation(), diag::err_using_enum_not_enum)
+ << TemplateId->Name->getName()
----------------
cor3ntin wrote:
We don't do it for base specifier, so i think this is fine (I suspect improvements would be a bit difficult, maybe by calling `ClassifyName`)
https://github.com/llvm/llvm-project/pull/95399
More information about the cfe-commits
mailing list