[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
Wed Feb 7 11:08:59 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:
> > ISO C++ does not permits this declaration to be declared as friend because 'enum E' is an elaborated enum specifier.
>
> There. Something along these lines
Not a huge fan of this phrasing. The wording of the diagnostic should already imply that such a declaration is invalid. Moreover:
- "elaborated enum specifier" isn't any "more correct" than "elaborated enum type"
- "declaration to be declared" is a bit redundant
- the phrasing implies that the declaration might be well-formed when written without `friend` (which it isn't).
https://github.com/llvm/llvm-project/pull/80171
More information about the cfe-commits
mailing list