From 1ba0cbc3f3fc1d7982c36172ffd0e72245593e6c Mon Sep 17 00:00:00 2001 From: Mital Ashok Date: Fri, 26 Jul 2024 13:34:00 +0100 Subject: [PATCH 1/4] [clang][Tests][NFC] Add CWG713 test; add example from CWG1584 test https://cplusplus.github.io/CWG/issues/713.html https://cplusplus.github.io/CWG/issues/1584.html --- clang/test/CXX/drs/cwg15xx.cpp | 48 ++++++++++++++++++++++------------ clang/test/CXX/drs/cwg7xx.cpp | 18 ++++++++++++- clang/www/cxx_dr_status.html | 2 +- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/clang/test/CXX/drs/cwg15xx.cpp b/clang/test/CXX/drs/cwg15xx.cpp index 21a392a5141e3f..961c25000111a0 100644 --- a/clang/test/CXX/drs/cwg15xx.cpp +++ b/clang/test/CXX/drs/cwg15xx.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,since-cxx11,cxx11-14 -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,since-cxx11,cxx11-14,cxx14-17 -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors @@ -6,6 +6,11 @@ // RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx23,since-cxx20,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx23,since-cxx20,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors +#if __cplusplus == 199711L +#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__) +// cxx98-error@-1 {{variadic macros are a C99 feature}} +#endif + namespace cwg1512 { // cwg1512: 4 void f(char *p) { if (p > 0) {} @@ -556,24 +561,33 @@ auto CWG1579_lambda_invalid = []() -> GenericMoveOnly { } // end namespace cwg1579 namespace cwg1584 { // cwg1584: 7 drafting 2015-05 -#if __cplusplus >= 201103L - // Deducing function types from cv-qualified types - template void f(const T *); // #cwg1584-f - template void g(T *, const T * = 0); - template void h(T *) { T::error; } - // since-cxx11-error@-1 {{type 'void ()' cannot be used prior to '::' because it has no members}} - // since-cxx11-note@#cwg1584-h {{in instantiation of function template specialization 'cwg1584::h' requested here}} - template void h(const T *); - void i() { - f(&i); - // since-cxx11-error@-1 {{no matching function for call to 'f'}} - // since-cxx11-note@#cwg1584-f {{candidate template ignored: could not match 'const T *' against 'void (*)()'}} - g(&i); - h(&i); // #cwg1584-h - } -#endif +// Deducing function types from cv-qualified types +template void f(const T *); // #cwg1584-f +template void g(T *, const T * = 0); +template void h(T *) { T::error; } +// expected-error@-1 {{type 'void ()' cannot be used prior to '::' because it has no members}} +// expected-note@#cwg1584-h {{in instantiation of function template specialization 'cwg1584::h' requested here}} +template void h(const T *); +void i() { + f(&i); + // expected-error@-1 {{no matching function for call to 'f'}} + // expected-note@#cwg1584-f {{candidate template ignored: could not match 'const T *' against 'void (*)()'}} + g(&i); + h(&i); // #cwg1584-h } +template struct tuple_size { + static const bool is_primary = true; +}; +template struct tuple_size : tuple_size { + static const bool is_primary = false; +}; + +tuple_size t; +static_assert(tuple_size::is_primary, ""); +static_assert(tuple_size::is_primary, ""); +} // namespace cwg1584 + namespace cwg1589 { // cwg1589: 3.7 c++11 #if __cplusplus >= 201103L // Ambiguous ranking of list-initialization sequences diff --git a/clang/test/CXX/drs/cwg7xx.cpp b/clang/test/CXX/drs/cwg7xx.cpp index 6d93e2948dadbf..1e5d3c0873d8b3 100644 --- a/clang/test/CXX/drs/cwg7xx.cpp +++ b/clang/test/CXX/drs/cwg7xx.cpp @@ -1,9 +1,14 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++98 %s -verify=expected,cxx98-14,cxx98-11 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++98 %s -verify=expected,cxx98,cxx98-14,cxx98-11 -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 %s -verify=expected,cxx98-14,cxx98-11,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++14 %s -verify=expected,cxx98-14,since-cxx14,since-cxx11,cxx14 -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++17 %s -verify=expected,since-cxx14,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++2a %s -verify=expected,since-cxx14,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors +#if __cplusplus == 199711L +#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__) +// cxx98-error@-1 {{variadic macros are a C99 feature}} +#endif + namespace cwg705 { // cwg705: yes namespace N { struct S {}; @@ -71,6 +76,17 @@ namespace cwg712 { // cwg712: partial #endif } +namespace cwg713 { // cwg713: yes +static_assert(!__is_const(void()const), ""); +static_assert(!__is_const(void()const volatile), ""); +static_assert(!__is_volatile(void()volatile), ""); +static_assert(!__is_volatile(void()const volatile), ""); +#if __cplusplus >= 201103L +static_assert(!__is_const(void()const&), ""); +static_assert(!__is_volatile(void()volatile&), ""); +#endif +} // namespace cwg713 + namespace cwg727 { // cwg727: partial struct A { template struct C; // #cwg727-C diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 937f67981e2963..3dd91be9ed9d35 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -4327,7 +4327,7 @@

C++ defect report implementation status

713 CD2 Unclear note about cv-qualified function types - Unknown + Yes 714 From 31560015df8c3349daa368d25ea86cbf4bae4aeb Mon Sep 17 00:00:00 2001 From: Mital Ashok Date: Fri, 26 Jul 2024 16:41:17 +0100 Subject: [PATCH 2/4] Make test work back up to Clang 3 --- clang/test/CXX/drs/cwg7xx.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/clang/test/CXX/drs/cwg7xx.cpp b/clang/test/CXX/drs/cwg7xx.cpp index 1e5d3c0873d8b3..c603b5a9614e33 100644 --- a/clang/test/CXX/drs/cwg7xx.cpp +++ b/clang/test/CXX/drs/cwg7xx.cpp @@ -77,13 +77,22 @@ namespace cwg712 { // cwg712: partial } namespace cwg713 { // cwg713: yes -static_assert(!__is_const(void()const), ""); -static_assert(!__is_const(void()const volatile), ""); -static_assert(!__is_volatile(void()volatile), ""); -static_assert(!__is_volatile(void()const volatile), ""); +template +struct is_const { + static const bool value = __is_const(T); +}; +template +struct is_volatile { + static const bool value = __is_volatile(T); +}; + +static_assert(!is_const::value, ""); +static_assert(!is_const::value, ""); +static_assert(!is_volatile::value, ""); +static_assert(!is_volatile::value, ""); #if __cplusplus >= 201103L -static_assert(!__is_const(void()const&), ""); -static_assert(!__is_volatile(void()volatile&), ""); +static_assert(!is_const::value, ""); +static_assert(!is_volatile::value, ""); #endif } // namespace cwg713 From f9f12642da952980709d29ac6025682e3eef2e0c Mon Sep 17 00:00:00 2001 From: Mital Ashok Date: Fri, 26 Jul 2024 16:43:11 +0100 Subject: [PATCH 3/4] Mark as Clang 2.5 --- clang/test/CXX/drs/cwg7xx.cpp | 2 +- clang/www/cxx_dr_status.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/CXX/drs/cwg7xx.cpp b/clang/test/CXX/drs/cwg7xx.cpp index c603b5a9614e33..36776a6e56412c 100644 --- a/clang/test/CXX/drs/cwg7xx.cpp +++ b/clang/test/CXX/drs/cwg7xx.cpp @@ -76,7 +76,7 @@ namespace cwg712 { // cwg712: partial #endif } -namespace cwg713 { // cwg713: yes +namespace cwg713 { // cwg713: 2.5 template struct is_const { static const bool value = __is_const(T); diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 3dd91be9ed9d35..5b1c6ce8900cde 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -4327,7 +4327,7 @@

C++ defect report implementation status

713 CD2 Unclear note about cv-qualified function types - Yes + Clang 2.5 714 From 87dfb54455198ca51fdaaa1d5a8dd5ddd37bed4d Mon Sep 17 00:00:00 2001 From: Mital Ashok Date: Fri, 26 Jul 2024 17:18:12 +0100 Subject: [PATCH 4/4] 2.5 -> 3.0 --- clang/test/CXX/drs/cwg7xx.cpp | 2 +- clang/www/cxx_dr_status.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/CXX/drs/cwg7xx.cpp b/clang/test/CXX/drs/cwg7xx.cpp index 36776a6e56412c..d120eb2487aff3 100644 --- a/clang/test/CXX/drs/cwg7xx.cpp +++ b/clang/test/CXX/drs/cwg7xx.cpp @@ -76,7 +76,7 @@ namespace cwg712 { // cwg712: partial #endif } -namespace cwg713 { // cwg713: 2.5 +namespace cwg713 { // cwg713: 3.0 template struct is_const { static const bool value = __is_const(T); diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index 5b1c6ce8900cde..81b0b6600a64ea 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -4327,7 +4327,7 @@

C++ defect report implementation status

713 CD2 Unclear note about cv-qualified function types - Clang 2.5 + Clang 3.0 714