[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 09:24:13 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'}}
+                       // expected-error at -1 {{elaborated enumeration type cannot be a friend}}
+};
----------------
Endilll wrote:

It would be nice to have a test case for unscoped enum with fixed underlying type, and also test cases when enum has been already declared by the point where it's befriended.

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


More information about the cfe-commits mailing list