[clang] [Clang][Sema] Diagnose friend declarations with enum elaborated-type-specifier in all language modes (PR #80171)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 6 10:17:31 PST 2024


================
@@ -1637,10 +1637,8 @@ def err_inline_namespace_std : Error<
 def err_unexpected_friend : Error<
   "friends can only be classes or functions">;
 def ext_enum_friend : ExtWarn<
-  "befriending enumeration type %0 is a C++11 extension">, InGroup<CXX11>;
-def warn_cxx98_compat_enum_friend : Warning<
-  "befriending enumeration type %0 is incompatible with C++98">,
-  InGroup<CXX98Compat>, DefaultIgnore;
+  "elaborated enumeration type cannot be a friend">,
----------------
Endilll wrote:

I think now I see what do you want to achieve. I definitely missed that enums can be befriended, just not using elaborated type specifier syntax. Sorry for some of the comments I left coming from a wrong perspective.

What if we skip complicated standardese altogether?
> 'enum' keyword is not allowed after `friend` keyword

Possibly followed by
> Omit 'enum' if you intend to befriend an enumeration 

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


More information about the cfe-commits mailing list