Author: Vlad Serebrennikov Date: 2024-01-14T02:27:01+04:00 New Revision: 91b53a2c791c65e17aa80dce7c357ff705d3fd4e
URL: https://github.com/llvm/llvm-project/commit/91b53a2c791c65e17aa80dce7c357ff705d3fd4e DIFF: https://github.com/llvm/llvm-project/commit/91b53a2c791c65e17aa80dce7c357ff705d3fd4e.diff LOG: [clang] Add tests for DRs about complete-class context (#77444) [P1787](https://wg21.link/p1787): The intent for CWG2335 (contra those of the older CWG1890, CWG1626, CWG1255, and CWG287) is supported by retaining the unrestricted forward lookup in complete-class contexts (despite current implementation behavior for non-templates). Wording: The declaration set is the result of a single search in the scope of C for N from immediately after the class-specifier of C if P is in a complete-class context of C or from P otherwise. [Drafting note: The plan for CWG2335 is to describe forbidden dependency cycles among the complete-class contexts of a class. — end drafting note] ([class.member.lookup]/4) Complete-class context is described in [class.mem.general] [p7](http://eel.is/c++draft/class#mem.general-7) and [p8](http://eel.is/c++draft/class#mem.general-8). In this patch I add tests only for CWG issues that fall under current definition of complete-class context, because I'm not sure how CWG1255 and CWG287 are going to work. That's why I skip over them, but mark CWG1308 as superseded by CWG1330. Added: clang/test/CXX/drs/dr2335.cpp Modified: clang/test/CXX/drs/dr13xx.cpp clang/test/CXX/drs/dr18xx.cpp clang/test/CXX/drs/dr23xx.cpp clang/www/cxx_dr_status.html Removed: ################################################################################ diff --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp index 366f58d9358003..0ff44ebbc95591 100644 --- a/clang/test/CXX/drs/dr13xx.cpp +++ b/clang/test/CXX/drs/dr13xx.cpp @@ -40,6 +40,8 @@ void caller() { #endif // __cplusplus >= 201103L } // namespace dr1307 +// dr1308: sup 1330 + namespace dr1310 { // dr1310: 5 struct S {} * sp = new S::S; // expected-error@-1 {{qualified reference to 'S' is a constructor name rather than a type in this context}} diff --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp index 1d76804907a5c1..175c39e8b73abb 100644 --- a/clang/test/CXX/drs/dr18xx.cpp +++ b/clang/test/CXX/drs/dr18xx.cpp @@ -329,6 +329,34 @@ namespace dr1881 { // dr1881: 7 static_assert(!__is_standard_layout(D), ""); } +namespace dr1890 { // dr1890: no drafting +// FIXME: current consensus for CWG2335 is that the examples are well-formed. +namespace ex1 { +#if __cplusplus >= 201402L +struct A { + struct B { + auto foo() { return 0; } // #dr1890-foo + }; + decltype(B().foo()) x; + // since-cxx14-error@-1 {{function 'foo' with deduced return type cannot be used before it is defined}} + // since-cxx14-note@#dr1890-foo {{'foo' declared here}} +}; +#endif +} // namespace ex1 + +namespace ex2 { +#if __cplusplus >= 201103L +struct Bar { + struct Baz { + int a = 0; + }; + static_assert(__is_constructible(Baz), ""); + // since-cxx11-error@-1 {{static assertion failed due to requirement '__is_constructible(dr1890::ex2::Bar::Baz)'}} +}; +#endif +} // namespace ex2 +} // namespace dr1890 + void dr1891() { // dr1891: 4 #if __cplusplus >= 201103L int n; diff --git a/clang/test/CXX/drs/dr2335.cpp b/clang/test/CXX/drs/dr2335.cpp new file mode 100644 index 00000000000000..d143aaf7cb0ac0 --- /dev/null +++ b/clang/test/CXX/drs/dr2335.cpp @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -std=c++98 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++11 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++14 %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++17 %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors + +#if __cplusplus <= 201103L +// expected-no-diagnostics +#endif + +namespace dr2335 { // dr2335: no drafting +// FIXME: current consensus is that the examples are well-formed. +#if __cplusplus >= 201402L +namespace ex1 { +template <class...> struct partition_indices { + static auto compute_right() {} + static constexpr auto right = compute_right; +}; +template struct partition_indices<int>; +} // namespace ex1 + +namespace ex2 { +template <int> struct X {}; +template <class T> struct partition_indices { + static auto compute_right() { return X<I>(); } + // since-cxx14-error@-1 {{no member 'I' in 'dr2335::ex2::partition_indices<int>'; it has not yet been instantiated}} + // since-cxx14-note@#dr2335-ex2-right {{in instantiation of member function 'dr2335::ex2::partition_indices<int>::compute_right' requested here}} + // since-cxx14-note@#dr2335-ex2-inst {{in instantiation of template class 'dr2335::ex2::partition_indices<int>' requested here}} + // since-cxx14-note@#dr2335-ex2-I {{not-yet-instantiated member is declared here}} + static constexpr auto right = compute_right; // #dr2335-ex2-right + static constexpr int I = sizeof(T); // #dr2335-ex2-I +}; +template struct partition_indices<int>; // #dr2335-ex2-inst +} // namespace ex2 + +namespace ex3 { +struct partition_indices { + static auto compute_right() {} // #dr2335-compute_right + static constexpr auto right = compute_right; // #dr2335-ex3-right + // since-cxx14-error@-1 {{function 'compute_right' with deduced return type cannot be used before it is defined}} + // since-cxx14-note@#dr2335-compute_right {{'compute_right' declared here}} + // since-cxx14-error@#dr2335-ex3-right {{declaration of variable 'right' with deduced type 'const auto' requires an initializer}} +}; +} // namespace ex3 +#endif +} // namespace dr2335 diff --git a/clang/test/CXX/drs/dr23xx.cpp b/clang/test/CXX/drs/dr23xx.cpp index d2f4e7652ab568..03077ae9239a45 100644 --- a/clang/test/CXX/drs/dr23xx.cpp +++ b/clang/test/CXX/drs/dr23xx.cpp @@ -48,6 +48,7 @@ void g() { #endif // dr2331: na +// dr2335 is in dr2335.cxx #if __cplusplus >= 201103L namespace dr2338 { // dr2338: 12 diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 5acc72dcf54b2d..397bf1357d3cb3 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -2662,7 +2662,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2> <td><a href="https://cplusplus.github.io/CWG/issues/437.html">437</a></td> <td>CD1</td> <td>Is type of class allowed in member function exception specification?</td> - <td class="unknown" align="center">Superseded by <a href="#1308">1308</a></td> + <td class="full" align="center">Superseded by <a href="#1308">1308</a></td> </tr> <tr id="438"> <td><a href="https://cplusplus.github.io/CWG/issues/438.html">438</a></td> @@ -7656,7 +7656,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2> <td><a href="https://cplusplus.github.io/CWG/issues/1308.html">1308</a></td> <td>CD3</td> <td>Completeness of class type within an <I>exception-specification</I></td> - <td class="unknown" align="center">Unknown</td> + <td class="full" align="center">Superseded by <a href="#1330">1330</a></td> </tr> <tr id="1309"> <td><a href="https://cplusplus.github.io/CWG/issues/1309.html">1309</a></td> @@ -11148,7 +11148,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2> <td><a href="https://cplusplus.github.io/CWG/issues/1890.html">1890</a></td> <td>drafting</td> <td>Member type depending on definition of member function</td> - <td align="center">Not resolved</td> + <td class="none" align="center">No</td> </tr> <tr id="1891"> <td><a href="https://cplusplus.github.io/CWG/issues/1891.html">1891</a></td> @@ -13818,7 +13818,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2> <td><a href="https://cplusplus.github.io/CWG/issues/2335.html">2335</a></td> <td>drafting</td> <td>Deduced return types vs member types</td> - <td align="center">Not resolved</td> + <td class="none" align="center">No</td> </tr> <tr id="2336"> <td><a href="https://cplusplus.github.io/CWG/issues/2336.html">2336</a></td> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits