Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ Resolutions to C++ Defect Reports

- Implemented `CWG3005 Function parameters should never be name-independent <https://wg21.link/CWG3005>`_.

- Implemented `CWG2496 ref-qualifiers and virtual overriding <https://wg21.link/CWG2496>`_.

C Language Changes
------------------

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New,
// If the function is a class member, its signature includes the
// cv-qualifiers (if any) and ref-qualifier (if any) on the function itself.
auto DiagnoseInconsistentRefQualifiers = [&]() {
if (SemaRef.LangOpts.CPlusPlus23)
if (SemaRef.LangOpts.CPlusPlus23 && !UseOverrideRules)
return false;
if (OldMethod->getRefQualifier() == NewMethod->getRefQualifier())
return false;
Expand Down
20 changes: 20 additions & 0 deletions clang/test/CXX/drs/cwg24xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,23 @@ 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(); // expected-note {{previous declaration is here}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave a bookmark here, and move the notes after their respective errors

virtual void g() &; // expected-note {{previous declaration is here}}
virtual void h(); // expected-note {{previous declaration is here}}
};

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}}
virtual void g();
Copy link
Collaborator

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.

Copy link
Contributor

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() case

Copy link
Contributor Author

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 :)

// expected-error@-1 {{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&'}}
virtual void h() &&;
// expected-error@-1 {{cannot overload a member function with ref-qualifier '&&' with a member function without a ref-qualifier}}
};
#endif
}
2 changes: 1 addition & 1 deletion clang/www/cxx_dr_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -14811,7 +14811,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/2496.html">2496</a></td>
<td>CD6</td>
<td><I>ref-qualifier</I>s and virtual overriding</td>
<td class="unknown" align="center">Unknown</td>
<td class="unreleased" align="center">Clang 21</td>
</tr>
<tr class="open" id="2497">
<td><a href="https://cplusplus.github.io/CWG/issues/2497.html">2497</a></td>
Expand Down
Loading