diff --git a/clang/test/CXX/drs/cwg11xx.cpp b/clang/test/CXX/drs/cwg11xx.cpp index 46a0e526be390..8d187041400a6 100644 --- a/clang/test/CXX/drs/cwg11xx.cpp +++ b/clang/test/CXX/drs/cwg11xx.cpp @@ -4,6 +4,21 @@ // RUN: %clang_cc1 -std=c++17 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++2a %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors +namespace cwg1110 { // cwg1110: 3.1 +#if __cplusplus >= 201103L +template +T return_T(); + +struct A; + +template +struct B; + +decltype(return_T())* a; +decltype(return_T>())* b; +#endif +} // namespace cwg1110 + namespace cwg1111 { // cwg1111: 3.2 namespace example1 { template struct set; // #cwg1111-struct-set diff --git a/clang/test/CXX/drs/cwg13xx.cpp b/clang/test/CXX/drs/cwg13xx.cpp index a334b6d01acf5..416de7c536b1a 100644 --- a/clang/test/CXX/drs/cwg13xx.cpp +++ b/clang/test/CXX/drs/cwg13xx.cpp @@ -306,6 +306,18 @@ namespace cwg1330 { // cwg1330: 4 c++11 // cwg1334: sup 1719 +namespace cwg1340 { // cwg1340: 2.9 +struct A; +struct B; + +void f(B* a, A B::* p) { + (*a).*p; + // expected-warning@-1 {{expression result unused}} + a->*p; + // expected-warning@-1 {{expression result unused}} +} +} // namespace cwg1340 + namespace cwg1341 { // cwg1341: sup P0683R1 #if __cplusplus >= 202002L int a; @@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // cwg1352: 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); +#endif + void f(int b = sizeof(A)); +}; + +template +struct B { +#if __cplusplus >= 201103L + int a = sizeof(B) + sizeof(T); +#endif + void f(int b = sizeof(B) + sizeof(T)); +}; + +template class B; +} // namespace cwg1352 + namespace cwg1358 { // cwg1358: 3.1 #if __cplusplus >= 201103L struct Lit { constexpr operator int() const { return 0; } }; diff --git a/clang/test/CXX/drs/cwg14xx.cpp b/clang/test/CXX/drs/cwg14xx.cpp index 9ff9a68dc13c3..f01d96ad47f3e 100644 --- a/clang/test/CXX/drs/cwg14xx.cpp +++ b/clang/test/CXX/drs/cwg14xx.cpp @@ -86,6 +86,23 @@ struct A { }; } +namespace cwg1458 { // cwg1458: 3.1 +#if __cplusplus >= 201103L +struct A; + +void f() { + constexpr A* a = nullptr; + constexpr int p = &*a; + // expected-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}} + constexpr A *p2 = &*a; +} + +struct A { + int operator&(); +}; +#endif +} // namespace cwg1458 + namespace cwg1460 { // cwg1460: 3.5 #if __cplusplus >= 201103L namespace DRExample { diff --git a/clang/test/CXX/drs/cwg18xx.cpp b/clang/test/CXX/drs/cwg18xx.cpp index 9eb749153e57a..89adc28384904 100644 --- a/clang/test/CXX/drs/cwg18xx.cpp +++ b/clang/test/CXX/drs/cwg18xx.cpp @@ -206,7 +206,7 @@ namespace cwg1814 { // cwg1814: yes #endif } -namespace cwg1815 { // cwg1815: yes +namespace cwg1815 { // cwg1815: 19 #if __cplusplus >= 201402L struct A { int &&r = 0; }; A a = {}; @@ -303,6 +303,32 @@ namespace cwg1822 { // cwg1822: yes #endif } +namespace cwg1824 { // cwg1824: 2.7 +template +struct A { + T t; +}; + +struct S { + A f() { return A(); } +}; +} // namespace cwg1824 + +namespace cwg1832 { // cwg1832: 3.0 +enum E { // #cwg1832-E + a = static_cast(static_cast(0)) + // expected-error@-1 {{'E' is an incomplete type}} + // expected-note@#cwg1832-E {{definition of 'cwg1832::E' is not complete until the closing '}'}} +}; + +#if __cplusplus >= 201103L +enum E2: decltype(static_cast(0), 0) {}; +// expected-error@-1 {{unknown type name 'E2'}} +enum class E3: decltype(static_cast(0), 0) {}; +// expected-error@-1 {{unknown type name 'E3'}} +#endif +} // namespace cwg1832 + namespace cwg1837 { // cwg1837: 3.3 #if __cplusplus >= 201103L template diff --git a/clang/test/CXX/drs/cwg23xx.cpp b/clang/test/CXX/drs/cwg23xx.cpp index db5b7c3cd3c9a..ae5ec3b878f59 100644 --- a/clang/test/CXX/drs/cwg23xx.cpp +++ b/clang/test/CXX/drs/cwg23xx.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -std=c++98 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s -// RUN: %clang_cc1 -std=c++11 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s -// RUN: %clang_cc1 -std=c++14 %s -verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s +// RUN: %clang_cc1 -std=c++11 %s -verify=expected,cxx11-14,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s +// RUN: %clang_cc1 -std=c++14 %s -verify=expected,cxx11-14,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s // RUN: %clang_cc1 -std=c++17 %s -verify=expected,since-cxx11,since-cxx14,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s // RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11,since-cxx14,since-cxx17,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s // RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11,since-cxx14,since-cxx17,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s @@ -47,6 +47,50 @@ void g() { } // namespace cwg2303 #endif +namespace cwg2304 { // cwg2304: 2.8 +template void foo(T, int); +template void foo(T&, ...); +struct Q; // #cwg2304-Q +void fn1(Q &data_vectors) { + foo(data_vectors, 0); + // expected-error@-1 {{argument type 'cwg2304::Q' is incomplete}} + // expected-note@#cwg2304-Q {{forward declaration of 'cwg2304::Q'}} +} +} // namespace cwg2304 + +namespace cwg2310 { // cwg2310: partial +#if __cplusplus >= 201103L +template +struct check_derived_from { + static A a; + // FIXME: all 3 examples should be rejected in all language modes. + // FIXME: we should test this in 98 mode. + // FIXME: we accept this when MSVC triple is used + static constexpr B *p = &a; +#if !defined(_WIN32) || defined(__MINGW32__) + // cxx11-14-error@-2 {{cannot initialize a variable of type 'cwg2310::X *const' with an rvalue of type 'cwg2310::Z *'}} + // cxx11-14-note@#cwg2310-X {{in instantiation of template class 'cwg2310::check_derived_from' requested here}} + // cxx11-14-error@-4 {{cannot initialize a variable of type 'cwg2310::Y *const' with an rvalue of type 'cwg2310::Z *'}} + // cxx11-14-note@#cwg2310-Y {{in instantiation of template class 'cwg2310::check_derived_from' requested here}} +#endif +}; + +struct W {}; +struct X {}; +struct Y {}; +struct Z : W, + X, check_derived_from, // #cwg2310-X + check_derived_from, Y // #cwg2310-Y +{ + // FIXME: It was properly rejected before, but we're crashing since Clang 11 in C++11 and C++14 modes. + // See https://github.com/llvm/llvm-project/issues/59920 +#if __cplusplus >= 201703L + check_derived_from cdf; +#endif +}; +#endif +} // namespace cwg2310 + // cwg2331: na // cwg2335 is in cwg2335.cxx diff --git a/clang/test/CXX/drs/cwg24xx.cpp b/clang/test/CXX/drs/cwg24xx.cpp index 9f876cd870834..75e1a614765c5 100644 --- a/clang/test/CXX/drs/cwg24xx.cpp +++ b/clang/test/CXX/drs/cwg24xx.cpp @@ -45,6 +45,12 @@ void fallthrough(int n) { #endif } +namespace cwg2430 { // cwg2430: 2.7 +struct S { + S f(S s) { return s; } +}; +} // namespace cwg2430 + namespace cwg2450 { // cwg2450: 18 #if __cplusplus >= 202302L struct S {int a;}; diff --git a/clang/test/CXX/drs/cwg25xx.cpp b/clang/test/CXX/drs/cwg25xx.cpp index 8bca58f44944f..0934f0cc19c6a 100644 --- a/clang/test/CXX/drs/cwg25xx.cpp +++ b/clang/test/CXX/drs/cwg25xx.cpp @@ -6,12 +6,21 @@ // RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx20,since-cxx23 -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx20,since-cxx23 -fexceptions -fcxx-exceptions -pedantic-errors -#if __cplusplus == 199711L -// expected-no-diagnostics -#endif +namespace std { +struct type_info{}; +} // namespace std // cwg2504 is in cwg2504.cpp +namespace cwg2512 { // cwg2512: 2.7 +struct A; // #cwg2512-A +void foo(A* p) { + typeid(*p); + // expected-error@-1 {{'typeid' of incomplete type 'A'}} + // expected-note@#cwg2512-A {{forward declaration of 'cwg2512::A'}} +} +} // namespace cwg2512 + namespace cwg2516 { // cwg2516: 3.0 // NB: reusing 1482 test #if __cplusplus >= 201103L diff --git a/clang/test/CXX/drs/cwg2630.cpp b/clang/test/CXX/drs/cwg2630.cpp new file mode 100644 index 0000000000000..0f50dc4f7458c --- /dev/null +++ b/clang/test/CXX/drs/cwg2630.cpp @@ -0,0 +1,23 @@ +// RUN: split-file --leading-lines %s %t +// RUN: %clang_cc1 -std=c++20 -verify -emit-module-interface %t/module.cppm -o %t/module.pcm +// RUN: %clang_cc1 -std=c++20 -verify -fmodule-file=A=%t/module.pcm %t/main.cpp +// RUN: %clang_cc1 -std=c++23 -verify -emit-module-interface %t/module.cppm -o %t/module.pcm +// RUN: %clang_cc1 -std=c++23 -verify -fmodule-file=A=%t/module.pcm %t/main.cpp +// RUN: %clang_cc1 -std=c++2c -verify -emit-module-interface %t/module.cppm -o %t/module.pcm +// RUN: %clang_cc1 -std=c++2c -verify -fmodule-file=A=%t/module.pcm %t/main.cpp + +//--- module.cppm +// expected-no-diagnostics +export module A; + +namespace cwg2630 { +export class X {}; +} // namespace cwg2630 + +//--- main.cpp +// expected-no-diagnostics +import A; + +namespace cwg2630 { // cwg2630: 9 +X x; +} // namespace cwg2630 diff --git a/clang/test/CXX/drs/cwg26xx.cpp b/clang/test/CXX/drs/cwg26xx.cpp index f7a05b9827a23..d3c5b5bb7b6b9 100644 --- a/clang/test/CXX/drs/cwg26xx.cpp +++ b/clang/test/CXX/drs/cwg26xx.cpp @@ -49,6 +49,8 @@ void f() { #endif } +// cwg2630 is in cwg2630.cpp + namespace cwg2631 { // cwg2631: 16 #if __cplusplus >= 202002L constexpr int g(); diff --git a/clang/test/CXX/drs/cwg27xx.cpp b/clang/test/CXX/drs/cwg27xx.cpp index 0434427d6c92a..53ddd566b7dbf 100644 --- a/clang/test/CXX/drs/cwg27xx.cpp +++ b/clang/test/CXX/drs/cwg27xx.cpp @@ -6,9 +6,17 @@ // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -verify=expected,since-cxx23 %s // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++2c -verify=expected,since-cxx23,since-cxx26 %s -#if __cplusplus <= 202002L -// expected-no-diagnostics -#endif +namespace cwg2718 { // cwg2718: 2.7 +struct B {}; +struct D; + +void f(B b) { + static_cast(b); + // expected-error@-1 {{non-const lvalue reference to type 'D' cannot bind to a value of unrelated type 'B'}} +} + +struct D : B {}; +} // namespace cwg2718 namespace cwg2759 { // cwg2759: 19 #if __cplusplus >= 201103L diff --git a/clang/test/CXX/drs/cwg28xx.cpp b/clang/test/CXX/drs/cwg28xx.cpp index be35d366bdd61..696cd1b9c84e7 100644 --- a/clang/test/CXX/drs/cwg28xx.cpp +++ b/clang/test/CXX/drs/cwg28xx.cpp @@ -6,10 +6,6 @@ // 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 -#if __cplusplus < 202002L -// expected-no-diagnostics -#endif - namespace cwg2819 { // cwg2819: 19 tentatively ready 2023-12-01 #if __cpp_constexpr >= 202306L constexpr void* p = nullptr; @@ -67,6 +63,30 @@ void B::g() requires true; } // namespace cwg2847 +namespace cwg2857 { // cwg2857: no +struct A {}; +template +struct D; +namespace N { + struct B {}; + void adl_only(A*, D*); // #cwg2857-adl_only +} + +void f(A* a, D* d) { + adl_only(a, d); + // expected-error@-1 {{use of undeclared identifier 'adl_only'; did you mean 'N::adl_only'?}} + // expected-note@#cwg2857-adl_only {{'N::adl_only' declared here}} +} + +#if __cplusplus >= 201103L +template +struct D : N::B { + // FIXME: ADL shouldn't associate it's base B and N since D is not complete here + decltype(adl_only((A*) nullptr, (D*) nullptr)) f; +}; +#endif +} // namespace cwg2857 + namespace cwg2858 { // cwg2858: 19 tentatively ready 2024-04-05 #if __cplusplus > 202302L diff --git a/clang/test/CXX/drs/cwg9xx.cpp b/clang/test/CXX/drs/cwg9xx.cpp index 8ecb149c355f6..2700b0f5662a2 100644 --- a/clang/test/CXX/drs/cwg9xx.cpp +++ b/clang/test/CXX/drs/cwg9xx.cpp @@ -14,6 +14,13 @@ namespace std { }; } +namespace cwg930 { // cwg930: 2.7 +#if __cplusplus >= 201103L +static_assert(alignof(int[]) == alignof(int), ""); +static_assert(alignof(int[][2]) == alignof(int[2]), ""); +#endif +} // namespace cwg930 + namespace cwg948 { // cwg948: 3.7 #if __cplusplus >= 201103L class A { diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 92fdcf5556ede..abf5d4ae4676d 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -5388,7 +5388,7 @@

C++ defect report implementation status

930 CD2 alignof with incomplete array type - Unknown + Clang 2.7 931 @@ -6468,7 +6468,7 @@

C++ defect report implementation status

1110 NAD Incomplete return type should be allowed in decltype operand - Unknown + Clang 3.1 1111 @@ -7848,7 +7848,7 @@

C++ defect report implementation status

1340 CD3 Complete type in member pointer expressions - Unknown + Clang 2.9 1341 @@ -7920,7 +7920,7 @@

C++ defect report implementation status

1352 CD3 Inconsistent class scope and completeness rules - Unknown + Clang 3.0 1353 @@ -8556,7 +8556,7 @@

C++ defect report implementation status

1458 CD3 Address of incomplete type vs operator&() - Unknown + Clang 3.1 1459 @@ -10752,7 +10752,7 @@

C++ defect report implementation status

1824 CD4 Completeness of return type vs point of instantiation - Unknown + Clang 2.7 1825 @@ -10800,7 +10800,7 @@

C++ defect report implementation status

1832 CD4 Casting to incomplete enumeration - Unknown + Clang 3.0 1833 @@ -13632,7 +13632,7 @@

C++ defect report implementation status

2304 NAD Incomplete type vs overload resolution - Unknown + Clang 2.8 2305 @@ -13668,7 +13668,7 @@

C++ defect report implementation status

2310 CD5 Type completeness and derived-to-base pointer conversions - Unknown + Partial 2311 @@ -14388,7 +14388,7 @@

C++ defect report implementation status

2430 C++20 Completeness of return and parameter types of member functions - Unknown + Clang 2.7 2431 @@ -14880,7 +14880,7 @@

C++ defect report implementation status

2512 NAD typeid and incomplete class types - Unknown + Clang 2.7 2513 @@ -15588,7 +15588,7 @@

C++ defect report implementation status

2630 C++23 Syntactic specification of class completeness - Unknown + Clang 9 2631 @@ -16116,7 +16116,7 @@

C++ defect report implementation status

2718 DRWP Type completeness for derived-to-base conversions - Unknown + Clang 2.7 2719 @@ -16951,7 +16951,7 @@

C++ defect report implementation status

2857 DR Argument-dependent lookup with incomplete class types - Unknown + No 2858 @@ -16985,7 +16985,7 @@

C++ defect report implementation status

2863 - tentatively ready + drafting Unclear synchronization requirements for object lifetime rules Not resolved @@ -17021,13 +17021,13 @@

C++ defect report implementation status

2869 - open + review this in local classes Not resolved 2870 - open + review Combining absent encoding-prefixes Not resolved @@ -17138,6 +17138,18 @@

C++ defect report implementation status

open Missing cases for reference and array types for argument-dependent lookup Not resolved + + + 2889 + open + Requiring an accessible destructor for destroying operator delete + Not resolved + + + 2890 + open + Defining members of local classes + Not resolved