[clang] 3f950ad - [clang] Add test for CWG360

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 1 06:24:28 PST 2022


Author: Vlad Serebrennikov
Date: 2022-12-01T17:23:26+03:00
New Revision: 3f950ad58919309882a29bcb4bf6f8db62ffc384

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

LOG: [clang] Add test for CWG360

P1787: "CWG360 is resolved by applying access control to using-declarations."
[[ http://eel.is/c++draft/class.access#general-4.sentence-3 | class.access.general#4 ]]: "When a using-declarator is named, access control is applied to it, not to the declarations that replace it."

Reviewed By: #clang-language-wg, aaron.ballman

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/test/CXX/drs/dr3xx.cpp b/clang/test/CXX/drs/dr3xx.cpp
index 4ae56fcdc93a3..de7f6b9bbf1d1 100644
--- a/clang/test/CXX/drs/dr3xx.cpp
+++ b/clang/test/CXX/drs/dr3xx.cpp
@@ -890,6 +890,33 @@ namespace dr359 { // dr359: yes
   };
 }
 
+namespace dr360 { // dr360: yes
+struct A {
+  int foo();
+  int bar();
+
+protected:
+  int baz();
+};
+
+struct B : A {
+private:
+  using A::foo; // #dr360-foo-using-decl
+protected:
+  using A::bar; // #dr360-bar-using-decl
+public:
+  using A::baz; // #dr360-baz-using-decl
+};
+
+int main() {
+  int foo = B().foo(); // expected-error {{is a private member}}
+  // expected-note@#dr360-foo-using-decl {{declared private here}}
+  int bar = B().bar(); // expected-error {{is a protected member}}
+  // expected-note@#dr360-bar-using-decl {{declared protected here}}
+  int baz = B().baz();
+}
+} // namespace dr360
+
 // dr362: na
 // dr363: na
 

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index cec9fe58cf601..e4d0a24e08c99 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -2200,7 +2200,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://wg21.link/cwg360">360</a></td>
     <td>CD6</td>
     <td>Using-declaration that reduces access</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr class="open" id="361">
     <td><a href="https://wg21.link/cwg361">361</a></td>


        


More information about the cfe-commits mailing list