[clang] [clang] Add test for CWG156 "Name lookup for conversion functions" (PR #121654)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 5 03:13:38 PST 2025


https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/121654

>From dcd29ca8c77e24c532ca8300a7e46f5498ffebbb Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Sat, 4 Jan 2025 19:37:46 +0300
Subject: [PATCH 1/2] [clang] Add test for CWG156 "Name lookup for conversion
 functions"

---
 clang/test/CXX/drs/cwg1xx.cpp | 43 +++++++++++++++++++++++++++++++++++
 clang/www/cxx_dr_status.html  |  2 +-
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/clang/test/CXX/drs/cwg1xx.cpp b/clang/test/CXX/drs/cwg1xx.cpp
index 6aec8b65c91f12..eddad2e6a87b00 100644
--- a/clang/test/CXX/drs/cwg1xx.cpp
+++ b/clang/test/CXX/drs/cwg1xx.cpp
@@ -922,6 +922,49 @@ namespace cwg155 { // cwg155: dup 632
   // expected-warning at -1 {{braces around scalar initializer}}
 }
 
+namespace cwg156 { // cwg156: partial
+namespace ex1 {
+struct A {
+  operator int();
+} a;
+void foo() {
+  typedef int T;
+  a.operator T(); // T is found using unqualified lookup
+                  // after qualified lookup in A fails.
+}
+} // namespace ex1
+
+namespace ex2 {
+struct A {
+  typedef int T;
+  operator T();
+};
+struct B : A {
+  operator T();
+} b;
+void foo() {
+  b.A::operator T(); // FIXME: qualified lookup should find T in A.
+  // expected-error at -1 {{unknown type name 'T'}}
+}
+} // namespace ex2
+
+namespace ex3 {
+template <class T1> struct A {
+  operator T1();
+};
+template <class T2> struct B : A<T2> {
+  operator T2();
+  void foo() {
+    // In both cases, during instantiation, qualified lookup for T2 wouldn't be able
+    // to find anything, so T2 has to be found by unqualified lookup.
+    // After that, 'operator T2()' is found in A<T2> by qualfied lookup.
+    T2 a = A<T2>::operator T2();
+    T2 b = ((A<T2> *)this)->operator T2();
+  }
+};
+} // namespace ex3
+} // namespace cwg156
+
 // cwg158 is in cwg158.cpp
 
 namespace cwg159 { // cwg159: 3.5
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index c069e155fd547c..bbdca49aad0533 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -981,7 +981,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://cplusplus.github.io/CWG/issues/156.html">156</a></td>
     <td>NAD</td>
     <td>Name lookup for conversion functions</td>
-    <td class="unknown" align="center">Unknown</td>
+    <td class="partial" align="center">Partial</td>
   </tr>
   <tr class="open" id="157">
     <td><a href="https://cplusplus.github.io/CWG/issues/157.html">157</a></td>

>From 1904c0963739e68660aab410702dea7355f746c6 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Sun, 5 Jan 2025 14:13:20 +0300
Subject: [PATCH 2/2] Merge CWG156 test into CWG111 test, and downgrade CWG1111
 to partial

---
 clang/test/CXX/drs/cwg11xx.cpp | 44 +++++++++++++++++++++++++++++++++-
 clang/test/CXX/drs/cwg1xx.cpp  | 44 +---------------------------------
 clang/www/cxx_dr_status.html   |  4 ++--
 3 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/clang/test/CXX/drs/cwg11xx.cpp b/clang/test/CXX/drs/cwg11xx.cpp
index 8d187041400a60..d33ff060d2d39e 100644
--- a/clang/test/CXX/drs/cwg11xx.cpp
+++ b/clang/test/CXX/drs/cwg11xx.cpp
@@ -19,7 +19,7 @@ decltype(return_T<B<int>>())* b;
 #endif
 } // namespace cwg1110
 
-namespace cwg1111 { // cwg1111: 3.2
+namespace cwg1111 { // cwg1111: partial
 namespace example1 {
 template <typename> struct set; // #cwg1111-struct-set
 
@@ -57,6 +57,48 @@ void baz() {
   a.operator A();
 }
 } // namespace example2
+
+namespace example3 {
+struct A {
+  operator int();
+} a;
+void foo() {
+  typedef int T;
+  a.operator T(); // T is found using unqualified lookup
+                  // after qualified lookup in A fails.
+}
+} // namespace example3
+
+namespace example4 {
+struct A {
+  typedef int T; // #cwg1111-A-T
+  operator T();
+};
+struct B : A {
+  operator T();
+} b;
+void foo() {
+  b.A::operator T(); // FIXME: qualified lookup should find T in A.
+  // expected-error at -1 {{unknown type name 'T'}}
+  //   expected-note@#cwg1111-A-T {{'A::T' declared here}}
+}
+} // namespace example4
+
+namespace example5 {
+template <class T1> struct A {
+  operator T1();
+};
+template <class T2> struct B : A<T2> {
+  operator T2();
+  void foo() {
+    // In both cases, during instantiation, qualified lookup for T2 wouldn't be able
+    // to find anything, so T2 has to be found by unqualified lookup.
+    // After that, 'operator T2()' is found in A<T2> by qualfied lookup.
+    T2 a = A<T2>::operator T2();
+    T2 b = ((A<T2> *)this)->operator T2();
+  }
+};
+} // namespace example5
 } // namespace cwg1111
 
 namespace cwg1113 { // cwg1113: partial
diff --git a/clang/test/CXX/drs/cwg1xx.cpp b/clang/test/CXX/drs/cwg1xx.cpp
index eddad2e6a87b00..6a26857bb80285 100644
--- a/clang/test/CXX/drs/cwg1xx.cpp
+++ b/clang/test/CXX/drs/cwg1xx.cpp
@@ -922,49 +922,7 @@ namespace cwg155 { // cwg155: dup 632
   // expected-warning at -1 {{braces around scalar initializer}}
 }
 
-namespace cwg156 { // cwg156: partial
-namespace ex1 {
-struct A {
-  operator int();
-} a;
-void foo() {
-  typedef int T;
-  a.operator T(); // T is found using unqualified lookup
-                  // after qualified lookup in A fails.
-}
-} // namespace ex1
-
-namespace ex2 {
-struct A {
-  typedef int T;
-  operator T();
-};
-struct B : A {
-  operator T();
-} b;
-void foo() {
-  b.A::operator T(); // FIXME: qualified lookup should find T in A.
-  // expected-error at -1 {{unknown type name 'T'}}
-}
-} // namespace ex2
-
-namespace ex3 {
-template <class T1> struct A {
-  operator T1();
-};
-template <class T2> struct B : A<T2> {
-  operator T2();
-  void foo() {
-    // In both cases, during instantiation, qualified lookup for T2 wouldn't be able
-    // to find anything, so T2 has to be found by unqualified lookup.
-    // After that, 'operator T2()' is found in A<T2> by qualfied lookup.
-    T2 a = A<T2>::operator T2();
-    T2 b = ((A<T2> *)this)->operator T2();
-  }
-};
-} // namespace ex3
-} // namespace cwg156
-
+// cwg156: sup 1111
 // cwg158 is in cwg158.cpp
 
 namespace cwg159 { // cwg159: 3.5
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index bbdca49aad0533..e00f5a09fc220f 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -981,7 +981,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://cplusplus.github.io/CWG/issues/156.html">156</a></td>
     <td>NAD</td>
     <td>Name lookup for conversion functions</td>
-    <td class="partial" align="center">Partial</td>
+    <td class="partial-superseded" align="center">Superseded by <a href="#1111">1111</a></td>
   </tr>
   <tr class="open" id="157">
     <td><a href="https://cplusplus.github.io/CWG/issues/157.html">157</a></td>
@@ -6485,7 +6485,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://cplusplus.github.io/CWG/issues/1111.html">1111</a></td>
     <td>C++11</td>
     <td>Remove dual-scope lookup of member template names</td>
-    <td class="full" align="center">Clang 3.2</td>
+    <td class="partial" align="center">Partial</td>
   </tr>
   <tr id="1112">
     <td><a href="https://cplusplus.github.io/CWG/issues/1112.html">1112</a></td>



More information about the cfe-commits mailing list