[clang] [Clang] Implement CWG2496 (PR #142975)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 9 08:35:38 PDT 2025
================
@@ -215,3 +215,32 @@ void (*q)() throw() = S();
// since-cxx17-error at -1 {{no viable conversion from 'S' to 'void (*)() throw()'}}
// since-cxx17-note@#cwg2486-conv {{candidate function}}
} // namespace cwg2486
+
+
+namespace cwg2496 { // cwg2496: 21
+#if __cplusplus >= 201102L
+struct S {
+ virtual void f(); // #cwg2496-f
+ virtual void g() &; // #cwg2496-g
+ virtual void h(); // #cwg2496-h
+ virtual void i();
+ virtual void j() &;
+ virtual void k() &&;
+};
+
+struct T : S {
+ virtual void f() &;
+ // expected-error at -1 {{cannot overload a member function with ref-qualifier '&' with a member function without a ref-qualifier}}
+ // expected-note@#cwg2496-f {{previous declaration is here}}
+ virtual void g();
----------------
AaronBallman wrote:
I'd also like to see a case where it's declared as `&` in the base class and `&&` in the derived class.
https://github.com/llvm/llvm-project/pull/142975
More information about the cfe-commits
mailing list