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

Krystian Stasiowski via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 6 09:52:19 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">,
----------------
sdkrystian wrote:

@Endilll I tried to follow the existing "naming convention" used in other diagnostics to strike a balance between being correct & comprehensible for users. Removing "elaborated" isn't quite correct because an enumeration type _can_ be a friend (e.g. `enum class E; struct A { friend E; };`; such a declaration is ignored) -- you just can't declare a friend using an elaborated-type-specifier starting with `enum` (i.e. `friend enum E`). 

Here is an alternative if you think changing this is necessary:
> A friend declaration cannot use an elaborated type specifier starting with `enum`



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


More information about the cfe-commits mailing list