Endill created this revision. Endill added a reviewer: clang-language-wg. Herald added a project: All. Endill requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
P1787 <https://reviews.llvm.org/P1787>: // CWG952 <https://wg21.link/cwg952> is resolved by refining the definition of “naming class” per Richard’s suggestion in “CWG1621 and [class.static/2” <https://lists.isocpp.org/core/2020/09/9963.php>.// Wording: - [class.static]/2 removed; - [class.access.base]/5 rephrased. Currently behavior is the following: unqualified names undergo //unqualified name lookup// [1], which perform //unqualified search// in immediate scope [2]. This scope is the scope the definition of //naming class// [3] refers to. `A::I` is not //accessible// when named in classes `C` and `D` per [3]. In particular, the last item regarding base class ([class.access.base]/5.4) is not applicable, because class `A` is not //accessible// in both classes `C` and `D` per [4]. References: 1. basic.lookup.unqual/4 <https://eel.is/c++draft/basic.lookup#unqual-4.sentence-2> 2. basic.lookup.unqual/3 <https://eel.is/c++draft/basic.lookup#unqual-3> 3. class.access.base/5 <https://eel.is/c++draft/class.access#base-5.sentence-4> 4. class.access.base/4 <https://eel.is/c++draft/class.access#base-4> Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D139326 Files: clang/test/CXX/drs/dr9xx.cpp clang/www/cxx_dr_status.html Index: clang/www/cxx_dr_status.html =================================================================== --- clang/www/cxx_dr_status.html +++ clang/www/cxx_dr_status.html @@ -5520,7 +5520,7 @@ <td><a href="https://wg21.link/cwg952">952</a></td> <td>CD6</td> <td>Insufficient description of “naming class”</td> - <td class="none" align="center">Unknown</td> + <td class="full" align="center">Yes</td> </tr> <tr id="953"> <td><a href="https://wg21.link/cwg953">953</a></td> Index: clang/test/CXX/drs/dr9xx.cpp =================================================================== --- clang/test/CXX/drs/dr9xx.cpp +++ clang/test/CXX/drs/dr9xx.cpp @@ -1,11 +1,9 @@ // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-no-diagnostics -#endif +// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions -pedantic-errors namespace std { __extension__ typedef __SIZE_TYPE__ size_t; @@ -74,6 +72,34 @@ #endif } +namespace dr952 { // dr952: yes +struct A { + typedef int I; // #dr952-typedef-decl +}; +struct B : private A { // #dr952-inheritance +}; +struct C : B { + void f() { + I i1; // expected-error {{private member}} + // expected-note@#dr952-inheritance {{constrained by private inheritance}} + // expected-note@#dr952-typedef-decl {{declared here}} + } + I i2; // expected-error {{private member}} + // expected-note@#dr952-inheritance {{constrained by private inheritance}} + // expected-note@#dr952-typedef-decl {{declared here}} + struct D { + I i3; // expected-error {{private member}} + // expected-note@#dr952-inheritance {{constrained by private inheritance}} + // expected-note@#dr952-typedef-decl {{declared here}} + void g() { + I i4; // expected-error {{private member}} + // expected-note@#dr952-inheritance {{constrained by private inheritance}} + // expected-note@#dr952-typedef-decl {{declared here}} + } + }; +}; +} // namespace dr952 + namespace dr974 { // dr974: yes #if __cplusplus >= 201103L void test() {
Index: clang/www/cxx_dr_status.html =================================================================== --- clang/www/cxx_dr_status.html +++ clang/www/cxx_dr_status.html @@ -5520,7 +5520,7 @@ <td><a href="https://wg21.link/cwg952">952</a></td> <td>CD6</td> <td>Insufficient description of “naming class”</td> - <td class="none" align="center">Unknown</td> + <td class="full" align="center">Yes</td> </tr> <tr id="953"> <td><a href="https://wg21.link/cwg953">953</a></td> Index: clang/test/CXX/drs/dr9xx.cpp =================================================================== --- clang/test/CXX/drs/dr9xx.cpp +++ clang/test/CXX/drs/dr9xx.cpp @@ -1,11 +1,9 @@ // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-no-diagnostics -#endif +// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions -pedantic-errors namespace std { __extension__ typedef __SIZE_TYPE__ size_t; @@ -74,6 +72,34 @@ #endif } +namespace dr952 { // dr952: yes +struct A { + typedef int I; // #dr952-typedef-decl +}; +struct B : private A { // #dr952-inheritance +}; +struct C : B { + void f() { + I i1; // expected-error {{private member}} + // expected-note@#dr952-inheritance {{constrained by private inheritance}} + // expected-note@#dr952-typedef-decl {{declared here}} + } + I i2; // expected-error {{private member}} + // expected-note@#dr952-inheritance {{constrained by private inheritance}} + // expected-note@#dr952-typedef-decl {{declared here}} + struct D { + I i3; // expected-error {{private member}} + // expected-note@#dr952-inheritance {{constrained by private inheritance}} + // expected-note@#dr952-typedef-decl {{declared here}} + void g() { + I i4; // expected-error {{private member}} + // expected-note@#dr952-inheritance {{constrained by private inheritance}} + // expected-note@#dr952-typedef-decl {{declared here}} + } + }; +}; +} // namespace dr952 + namespace dr974 { // dr974: yes #if __cplusplus >= 201103L void test() {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits