Skip to content

[clang][NFC] Add test for CWG1898 "Use of “equivalent” in overload resolution" #113439

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

Merged
merged 3 commits into from
Oct 25, 2024

Conversation

Endilll
Copy link
Contributor

@Endilll Endilll commented Oct 23, 2024

CWG1898 Use of “equivalent” in overload resolution

P1787R6:

CWG1898 is resolved by explicitly using the defined term parameter-type-list.

Except that now it's called non-object-parameter-type-list, which is defined in [dcl.fct] p8 and p4.

As for the wording, the first sentence _N4140_.[over.dcl]/1 where the word "equivalent" was used:

Two function declarations of the same name refer to the same function if they are in the same scope and have equivalent parameter declarations ([over.load]).

was replaced with what is now known as "corresponding overloads", defined in [basic.scope.scope]/4. The definition is present in P1787R6, but it's hard to reference, because the "corresponding overloads" term was coined later.

@Endilll Endilll added clang Clang issues not falling into any other category c++ labels Oct 23, 2024
@Endilll Endilll requested review from cor3ntin and shafik October 23, 2024 10:01
@llvmbot
Copy link
Member

llvmbot commented Oct 23, 2024

@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)

Changes

CWG1898 Use of “equivalent” in overload resolution

P1787R6:
> CWG1898 is resolved by explicitly using the defined term parameter-type-list.

As for the wording, the first sentence [over.dcl]/1 where the word "equivalent" was used:
> Two function declarations of the same name refer to the same function if they are in the same scope and have equivalent parameter declarations ([over.load]).

was replaced with what is now known as "corresponding overloads", defined in [basic.scope.scope]/4. The definition is present in P1787R6, but it's hard to reference, because the "corresponding overloads" term was coined later.


Full diff: https://github.com/llvm/llvm-project/pull/113439.diff

2 Files Affected:

  • (modified) clang/test/CXX/drs/cwg18xx.cpp (+45)
  • (modified) clang/www/cxx_dr_status.html (+1-1)
diff --git a/clang/test/CXX/drs/cwg18xx.cpp b/clang/test/CXX/drs/cwg18xx.cpp
index 7f0fb8cf589d48..3ec5c4d5c618b4 100644
--- a/clang/test/CXX/drs/cwg18xx.cpp
+++ b/clang/test/CXX/drs/cwg18xx.cpp
@@ -640,3 +640,48 @@ namespace H {
   struct S s;
 }
 }
+
+namespace cwg1898 { // cwg1898: 2.7
+void e(int) {} // #cwg1898-e-int
+void e(int) {}
+// expected-error@-1 {{redefinition of 'e'}}
+//   expected-note@#cwg1898-e-int {{previous definition is here}}
+void e(long) {}
+
+void f(int) {} // #cwg1898-f-int
+void f(const int) {}
+// expected-error@-1 {{redefinition of 'f'}}
+//   expected-note@#cwg1898-f-int {{previous definition is here}}
+
+void g(int) {} // #cwg1898-g-int
+void g(volatile int) {}
+// since-cxx20-warning@-1 {{volatile-qualified parameter type 'volatile int' is deprecated}}
+// expected-error@-2 {{redefinition of 'g'}}
+//   expected-note@#cwg1898-g-int {{previous definition is here}}
+
+void h(int *) {} // #cwg1898-h-int
+void h(int[]) {}
+// expected-error@-1 {{redefinition of 'h'}}
+//   expected-note@#cwg1898-h-int {{previous definition is here}}
+
+void i(int *) {} // #cwg1898-i-int
+void i(int[2]) {}
+// expected-error@-1 {{redefinition of 'i'}}
+//   expected-note@#cwg1898-i-int {{previous definition is here}}
+
+void j(void(*)()) {} // #cwg1898-j-int
+void j(void()) {}
+// expected-error@-1 {{redefinition of 'j'}}
+//   expected-note@#cwg1898-j-int {{previous definition is here}}
+
+struct A {
+  void k(int) {} // #cwg1898-k-int
+  void k(int) {}
+  // expected-error@-1 {{class member cannot be redeclared}}
+  //   expected-note@#cwg1898-k-int {{previous definition is here}}
+};
+
+struct B : A {
+  void k(int) {}
+};
+} // namespace cwg1898
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 82ba9b370ba595..6640ed477a241e 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -11219,7 +11219,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://cplusplus.github.io/CWG/issues/1898.html">1898</a></td>
     <td>CD6</td>
     <td>Use of &#8220;equivalent&#8221; in overload resolution</td>
-    <td class="unknown" align="center">Unknown</td>
+    <td class="full" align="center">Clang 2.7</td>
   </tr>
   <tr id="1899">
     <td><a href="https://cplusplus.github.io/CWG/issues/1899.html">1899</a></td>

Copy link
Contributor

@cor3ntin cor3ntin left a comment

Choose a reason for hiding this comment

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

LGTM

@Endilll Endilll merged commit e6917e9 into llvm:main Oct 25, 2024
8 checks passed
@Endilll Endilll deleted the cwg1898 branch October 25, 2024 17:15
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
…solution" (llvm#113439)

[CWG1898](https://cplusplus.github.io/CWG/issues/1898.html) Use of
“equivalent” in overload resolution
====================

[P1787R6](https://wg21.link/p1787r6):
> CWG1898 is resolved by explicitly using the defined term
parameter-type-list.

Except that now it's called non-object-parameter-type-list, which is
defined in [dcl.fct] [p8](https://eel.is/c++draft/dcl.fct#8) and
[p4](https://eel.is/c++draft/dcl.fct#8).

As for the wording, the first sentence
[\_N4140\_.[over.dcl]/1](https://timsong-cpp.github.io/cppwp/n4140/over.dcl#1)
where the word "equivalent" was used:
> Two function declarations of the same name refer to the same function
if they are in the same scope and have equivalent parameter declarations
([over.load]).

was replaced with what is now known as "corresponding overloads",
defined in
[[basic.scope.scope]/4](https://eel.is/c++draft/basic.scope#scope-4).
The definition is present in P1787R6, but it's hard to reference,
because the "corresponding overloads" term was coined later.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants