[clang] [clang][NFC] Add test for CWG1898 "Use of “equivalent” in overload resolution" (PR #113439)
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 25 08:30:20 PDT 2024
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/113439
>From 467c478cbc2400e1337e6dcc344a96e4a697341a Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Wed, 23 Oct 2024 12:59:36 +0300
Subject: [PATCH 1/3] =?UTF-8?q?[clang][NFC]=20Add=20test=20for=20CWG1898?=
=?UTF-8?q?=20"Use=20of=20=E2=80=9Cequivalent=E2=80=9D=20in=20overload=20r?=
=?UTF-8?q?esolution"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
clang/test/CXX/drs/cwg18xx.cpp | 45 ++++++++++++++++++++++++++++++++++
clang/www/cxx_dr_status.html | 2 +-
2 files changed, 46 insertions(+), 1 deletion(-)
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 at -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 at -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 at -1 {{volatile-qualified parameter type 'volatile int' is deprecated}}
+// expected-error at -2 {{redefinition of 'g'}}
+// expected-note@#cwg1898-g-int {{previous definition is here}}
+
+void h(int *) {} // #cwg1898-h-int
+void h(int[]) {}
+// expected-error at -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 at -1 {{redefinition of 'i'}}
+// expected-note@#cwg1898-i-int {{previous definition is here}}
+
+void j(void(*)()) {} // #cwg1898-j-int
+void j(void()) {}
+// expected-error at -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 at -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 “equivalent” 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>
>From 0a2d3e00991f1d88d3e875e4a005d9c1bbf8712a Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Fri, 25 Oct 2024 13:18:58 +0300
Subject: [PATCH 2/3] Address feedback and implement minor improvements
---
clang/test/CXX/drs/cwg18xx.cpp | 59 +++++++++++++++++++++++-----------
1 file changed, 41 insertions(+), 18 deletions(-)
diff --git a/clang/test/CXX/drs/cwg18xx.cpp b/clang/test/CXX/drs/cwg18xx.cpp
index 3ec5c4d5c618b4..bc9b7de683a146 100644
--- a/clang/test/CXX/drs/cwg18xx.cpp
+++ b/clang/test/CXX/drs/cwg18xx.cpp
@@ -642,46 +642,69 @@ namespace H {
}
namespace cwg1898 { // cwg1898: 2.7
-void e(int) {} // #cwg1898-e-int
+void e(int) {} // #cwg1898-e
void e(int) {}
// expected-error at -1 {{redefinition of 'e'}}
-// expected-note@#cwg1898-e-int {{previous definition is here}}
-void e(long) {}
+// expected-note@#cwg1898-e {{previous definition is here}}
-void f(int) {} // #cwg1898-f-int
+void e2(int) {}
+void e2(long) {} // OK, different type
+
+void f(int) {} // #cwg1898-f
void f(const int) {}
// expected-error at -1 {{redefinition of 'f'}}
-// expected-note@#cwg1898-f-int {{previous definition is here}}
+// expected-note@#cwg1898-f {{previous definition is here}}
-void g(int) {} // #cwg1898-g-int
+void g(int) {} // #cwg1898-g
void g(volatile int) {}
// since-cxx20-warning at -1 {{volatile-qualified parameter type 'volatile int' is deprecated}}
// expected-error at -2 {{redefinition of 'g'}}
-// expected-note@#cwg1898-g-int {{previous definition is here}}
+// expected-note@#cwg1898-g {{previous definition is here}}
-void h(int *) {} // #cwg1898-h-int
+void h(int *) {} // #cwg1898-h
void h(int[]) {}
// expected-error at -1 {{redefinition of 'h'}}
-// expected-note@#cwg1898-h-int {{previous definition is here}}
+// expected-note@#cwg1898-h {{previous definition is here}}
+
+void h2(int *) {} // #cwg1898-h2
+void h2(int[2]) {}
+// expected-error at -1 {{redefinition of 'h2'}}
+// expected-note@#cwg1898-h2 {{previous definition is here}}
+
+void h3(int (*)[2]) {} // #cwg1898-h3
+void h3(int [3][2]) {}
+// expected-error at -1 {{redefinition of 'h3'}}
+// expected-note@#cwg1898-h3 {{previous definition is here}}
+
+void h4(int (*)[2]) {}
+void h4(int [3][3]) {} // OK, differ in non-top-level extent of array
-void i(int *) {} // #cwg1898-i-int
-void i(int[2]) {}
-// expected-error at -1 {{redefinition of 'i'}}
-// expected-note@#cwg1898-i-int {{previous definition is here}}
+void i(int *) {}
+void i(const int *) {} // OK, pointee cv-qualification is not discarded
-void j(void(*)()) {} // #cwg1898-j-int
+void i2(int *) {} // #cwg1898-i2
+void i2(int * const) {}
+// expected-error at -1 {{redefinition of 'i2'}}
+// expected-note@#cwg1898-i2 {{previous definition is here}}
+
+void j(void(*)()) {} // #cwg1898-j
void j(void()) {}
// expected-error at -1 {{redefinition of 'j'}}
-// expected-note@#cwg1898-j-int {{previous definition is here}}
+// expected-note@#cwg1898-j {{previous definition is here}}
+
+void j2(void(int)) {} // #cwg1898-j2
+void j2(void(const int)) {}
+// expected-error at -1 {{redefinition of 'j2'}}
+// expected-note@#cwg1898-j2 {{previous definition is here}}
struct A {
- void k(int) {} // #cwg1898-k-int
+ void k(int) {} // #cwg1898-k
void k(int) {}
// expected-error at -1 {{class member cannot be redeclared}}
- // expected-note@#cwg1898-k-int {{previous definition is here}}
+ // expected-note@#cwg1898-k {{previous definition is here}}
};
struct B : A {
- void k(int) {}
+ void k(int) {} // OK, shadows A::k
};
} // namespace cwg1898
>From 31a2934b65cb55d51b36efa41da0c24772a97b04 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Fri, 25 Oct 2024 18:30:04 +0300
Subject: [PATCH 3/3] Add examples with ellipsis and parameter packs
---
clang/test/CXX/drs/cwg18xx.cpp | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/clang/test/CXX/drs/cwg18xx.cpp b/clang/test/CXX/drs/cwg18xx.cpp
index bc9b7de683a146..b059492637bd5c 100644
--- a/clang/test/CXX/drs/cwg18xx.cpp
+++ b/clang/test/CXX/drs/cwg18xx.cpp
@@ -707,4 +707,19 @@ struct A {
struct B : A {
void k(int) {} // OK, shadows A::k
};
+
+void l() {}
+void l(...) {}
+
+#if __cplusplus >= 201103L
+template <typename T>
+void m(T) {}
+template <typename... Ts>
+void m(Ts...) {}
+
+template <typename T, typename U>
+void m2(T, U) {}
+template <typename... Ts, typename U>
+void m2(Ts..., U) {}
+#endif
} // namespace cwg1898
More information about the cfe-commits
mailing list