[clang] [Clang] [Parser] Improve diagnostic for `friend concept` (PR #105121)

via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 20 13:20:51 PDT 2024


================
@@ -3139,6 +3139,19 @@ Parser::DeclGroupPtrTy Parser::ParseCXXClassMemberDeclaration(
     return Actions.BuildDeclaratorGroup(Decls);
   }
 
+  // Befriending a concept is invalid and would already fail if
+  // we did nothing here, but this allows us to issue a more
+  // helpful diagnostic.
+  if (Tok.is(tok::kw_concept)) {
----------------
Sirraide wrote:

> Could we get a standard reference for a befriending a concept being invalid.

Pretty sure the syntax just doesn’t allow for it: Neither a `simple-type-specifier`, nor an `elaborated-type-specifier`, nor a `typename-specifier` can start with `concept`. The grammatical productions for `friend-type-specifier` are already listed in the comment at the top of the function.

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


More information about the cfe-commits mailing list