[clang] feb93d2 - [clang] Add test for CWG2370

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 11 12:04:09 PDT 2023


Author: Vlad Serebrennikov
Date: 2023-04-11T22:04:02+03:00
New Revision: feb93d28b02c41ca6b069ec1f9e62fdfbb4c8b6c

URL: https://github.com/llvm/llvm-project/commit/feb93d28b02c41ca6b069ec1f9e62fdfbb4c8b6c
DIFF: https://github.com/llvm/llvm-project/commit/feb93d28b02c41ca6b069ec1f9e62fdfbb4c8b6c.diff

LOG: [clang] Add test for CWG2370

[[https://wg21.link/p1787 | P1787]]: CWG2370 is resolved by performing a search in (only) the immediate scope of any friend, per the [[ http://wiki.edg.com/bin/view/Wg21sandiego2018/CoreWorkingGroup#Core_issue_2370_friend_declarati | CWG opinion from San Diego ]].
Wording: In a friend declaration declarator whose declarator-id is a qualified-id whose lookup context is a class or namespace S, lookup for an unqualified name that appears after the declarator-id performs a search in the scope associated with S. If that lookup finds nothing, it undergoes unqualified name lookup. ([basic.lookup.unqual]/6).

Clarification for P1787 description: when applied to the test in this patch, "immediate scope" refers to `N`, and "(only)" refers to the fact that `type` is not searched in parent scope of `N`. See example after the wording if additional clarification is needed. The most relevant line there is `friend void A::f(F);  // OK`.

Reviewed By: #clang-language-wg, shafik

Differential Revision: https://reviews.llvm.org/D147848

Added: 
    

Modified: 
    clang/test/CXX/drs/dr23xx.cpp
    clang/www/cxx_dr_status.html

Removed: 
    


################################################################################
diff  --git a/clang/test/CXX/drs/dr23xx.cpp b/clang/test/CXX/drs/dr23xx.cpp
index a60aa8e5609c6..4f16746aad8be 100644
--- a/clang/test/CXX/drs/dr23xx.cpp
+++ b/clang/test/CXX/drs/dr23xx.cpp
@@ -2,7 +2,9 @@
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
+
 
 #if __cplusplus >= 201103L
 namespace dr2338 { // dr2338: 12
@@ -169,6 +171,20 @@ void g() {
 } //namespace dr2303
 #endif
 
+namespace dr2370 { // dr2370: no
+namespace N {
+typedef int type;
+void g(type);
+void h(type);
+} // namespace N
+class C {
+  typedef N::type N_type;
+  // FIXME: `type` should be searched for in N
+  // friend void N::g(type);
+  friend void N::h(N_type);
+};
+} // namespace dr2370
+
 // dr2385: na
 
 namespace dr2394 { // dr2394: 15

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 6e234f63fc015..863e20a57e2cd 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -14027,7 +14027,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://wg21.link/cwg2370">2370</a></td>
     <td>CD6</td>
     <td><TT>friend</TT> declarations of namespace-scope functions</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="none" align="center">No</td>
   </tr>
   <tr id="2371">
     <td><a href="https://wg21.link/cwg2371">2371</a></td>


        


More information about the cfe-commits mailing list