From 4f2dba3c0b4e5f11b968a840b5f70070f5288cfe Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Mon, 3 Jun 2024 13:47:28 +0400 Subject: [clang] Add tests for some CWG issues from 2024-05-31 telecon (#94167) This patch adds tests for some CWG issues that were discussed at 2024-05-31 telecon. While all of them are tentatively ready at the moment, I'm expecting them to be moved to DRs without changes. CWG issues that are expected to have follow-ups are not included in this PR. I also realized that `cwg28xx.cpp` has been testing without `-pedantic-errors`. I fixed that. Fortunately, no existing tests had anything hidden by the lack of this flag. The following CWG issues are covered: [CWG2877](https://cplusplus.github.io/CWG/issues/2877.html) "Type-only lookup for _using-enum-declarator_" [CWG2882](https://cplusplus.github.io/CWG/issues/2882.html) "Unclear treatment of conversion to `void`" [CWG2883](https://cplusplus.github.io/CWG/issues/2883.html) "Definition of "odr-usable" ignores lambda scopes" [CWG2885](https://cplusplus.github.io/CWG/issues/2885.html) "Non-eligible trivial default constructors" [CWG2886](https://cplusplus.github.io/CWG/issues/2886.html) "Temporaries and trivial potentially-throwing special member functions" --- clang/test/CXX/drs/cwg28xx.cpp | 95 ++++++++++++++++++++++++++++++++++++++---- clang/www/cxx_dr_status.html | 10 ++--- 2 files changed, 93 insertions(+), 12 deletions(-) diff --git a/clang/test/CXX/drs/cwg28xx.cpp b/clang/test/CXX/drs/cwg28xx.cpp index 8469a06..da81ecc 100644 --- a/clang/test/CXX/drs/cwg28xx.cpp +++ b/clang/test/CXX/drs/cwg28xx.cpp @@ -1,10 +1,10 @@ -// RUN: %clang_cc1 -std=c++98 -verify=expected %s -// RUN: %clang_cc1 -std=c++11 -verify=expected %s -// RUN: %clang_cc1 -std=c++14 -verify=expected %s -// RUN: %clang_cc1 -std=c++17 -verify=expected %s -// RUN: %clang_cc1 -std=c++20 -verify=expected,since-cxx20 %s -// RUN: %clang_cc1 -std=c++23 -verify=expected,since-cxx20,since-cxx23 %s -// RUN: %clang_cc1 -std=c++2c -verify=expected,since-cxx20,since-cxx23,since-cxx26 %s +// RUN: %clang_cc1 -std=c++98 -pedantic-errors -verify=expected,cxx98 %s +// RUN: %clang_cc1 -std=c++11 -pedantic-errors -verify=expected %s +// RUN: %clang_cc1 -std=c++14 -pedantic-errors -verify=expected %s +// RUN: %clang_cc1 -std=c++17 -pedantic-errors -verify=expected %s +// RUN: %clang_cc1 -std=c++20 -pedantic-errors -verify=expected,since-cxx20 %s +// RUN: %clang_cc1 -std=c++23 -pedantic-errors -verify=expected,since-cxx20,since-cxx23 %s +// RUN: %clang_cc1 -std=c++2c -pedantic-errors -verify=expected,since-cxx20,since-cxx23,since-cxx26 %s namespace cwg2819 { // cwg2819: 19 tentatively ready 2023-12-01 #if __cpp_constexpr >= 202306L @@ -110,6 +110,26 @@ struct A { } // namespace cwg2858 +namespace cwg2877 { // cwg2877: no tentatively ready 2024-05-31 +#if __cplusplus >= 202002L +enum E { x }; +void f() { + int E; + // FIXME: OK, names ::E + using enum E; + // since-cxx20-error@-1 {{unknown type name E}} +} +using F = E; +using enum F; // OK, designates ::E +template using EE = T; +void g() { + // FIXME: OK, designates ::E + using enum EE; + // since-cxx20-error@-1 {{using enum requires an enum or typedef name}} +} +#endif +} // namespace cwg2877 + namespace cwg2881 { // cwg2881: 19 tentatively ready 2024-04-19 #if __cplusplus >= 202302L @@ -180,3 +200,64 @@ void f() { } // namespace cwg2881 +namespace cwg2882 { // cwg2882: 2.7 tentatively ready 2024-05-31 +struct C { + operator void() = delete; + // expected-warning@-1 {{conversion function converting 'cwg2882::C' to 'void' will never be used}} + // cxx98-error@-2 {{deleted function definitions are a C++11 extension}} +}; + +void f(C c) { + (void)c; +} +} // namespace cwg2882 + +namespace cwg2883 { // cwg2883: no tentatively ready 2024-05-31 +#if __cplusplus >= 201103L +void f() { + int x; + (void)[&] { + return x; + }; +} +#endif +#if __cplusplus >= 202002L +struct A { + A() = default; + A(const A &) = delete; // #cwg2883-A-copy-ctor + constexpr operator int() { return 42; } +}; +void g() { + constexpr A a; + // FIXME: OK, not odr-usable from a default template argument, and not odr-used + (void)[=] {}; + // since-cxx20-error@-1 {{call to deleted constructor of 'const A'}} + // since-cxx20-note@#cwg2883-A-copy-ctor {{'A' has been explicitly marked deleted here}} +} +#endif +} // namespace cwg2883 + +namespace cwg2885 { // cwg2885: 16 tentatively ready 2024-05-31 +#if __cplusplus >= 202002L +template +struct A { + A() requires (false) = default; + A() : t(42) {} + T t; +}; + +struct B : A {}; +static_assert(!__is_trivially_constructible(B)); +#endif +} // namespace cwg2885 + +namespace cwg2886 { // cwg2886: 9 tentatively ready 2024-05-31 +#if __cplusplus >= 201103L +struct C { + C() = default; + ~C() noexcept(false) = default; +}; + +static_assert(noexcept(C()), ""); +#endif +} // namespace cwg2886 diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 744d229..4d94ac5 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -17071,7 +17071,7 @@ objects 2877 tentatively ready Type-only lookup for using-enum-declarator - Not resolved + Not Resolved* 2878 @@ -17101,13 +17101,13 @@ objects 2882 tentatively ready Unclear treatment of conversion to void - Not resolved + Not Resolved* 2883 tentatively ready Definition of "odr-usable" ignores lambda scopes - Not resolved + Not Resolved* 2884 @@ -17119,13 +17119,13 @@ objects 2885 tentatively ready Non-eligible trivial default constructors - Not resolved + Not Resolved* 2886 tentatively ready Temporaries and trivial potentially-throwing special member functions - Not resolved + Not Resolved* 2887 -- cgit v1.1