[clang] [Clang] Implement CWG2496 (PR #142975)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 9 09:23:11 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();
+ // expected-error at -1 {{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&'}}
+ // expected-note@#cwg2496-g {{previous declaration is here}}
+ virtual void h() &&;
+ // expected-error at -1 {{cannot overload a member function with ref-qualifier '&&' with a member function without a ref-qualifier}}
+ // expected-note@#cwg2496-h {{previous declaration is here}}
+ virtual void i();
+ virtual void j() &;
+ virtual void k() &;
----------------
AaronBallman wrote:
Ah, I see that wording now, you're right. And since they don't correspond, those are overloads not overrides.
https://github.com/llvm/llvm-project/pull/142975
More information about the cfe-commits
mailing list