-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang] Implement CWG2496 #142975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clang] Implement CWG2496 #142975
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,3 +215,34 @@ void (*q)() throw() = S(); | |
// since-cxx17-error@-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() &&; | ||
virtual void l() &; | ||
}; | ||
|
||
struct T : S { | ||
virtual void f() &; | ||
// expected-error@-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@-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@-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() &; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be diagnosed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the two functions don't correspond. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see that wording now, you're right. And since they don't correspond, those are overloads not overrides. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you leave a comment in the test about that? |
||
virtual void l() &&; | ||
}; | ||
#endif | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also like to see a case where it's declared as
&
in the base class and&&
in the derived class.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is
l()
caseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added the l case afterwards :)