[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 11:57:59 PST 2024


================
@@ -252,4 +252,14 @@ namespace dr2397 { // dr2397: 17
     auto (*c)[5] = &a;
   }
 } // namespace dr2397
+
+// CWG2363 was closed as NAD, but its resolution does affirm that
+// a friend declaration cannot have an opaque-enumm-specifier.
+namespace dr2363 { // dr2363: yes
+struct A {
+  friend enum class E; // since-cxx11-error {{reference to enumeration must use 'enum' not 'enum class'}}
----------------
sdkrystian wrote:

@Endilll like so?
```cpp
struct A {
  friend enum class E;
  // since-cxx11-error at -1 {{reference to enumeration must use 'enum' not 'enum class'}}
  // expected-error at -2 {{elaborated enumeration type cannot be a friend}}
};
```

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


More information about the cfe-commits mailing list