Skip to content

Commit

Permalink
[clang][NFC] Add CWG713 test; add example from CWG1584 test (llvm#100747
Browse files Browse the repository at this point in the history
  • Loading branch information
MitalAshok authored Aug 5, 2024
1 parent 39826b1 commit 30e5d71
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 19 deletions.
48 changes: 31 additions & 17 deletions clang/test/CXX/drs/cwg15xx.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
// 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
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,since-cxx20,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors
// 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) {}
Expand Down Expand Up @@ -556,24 +561,33 @@ auto CWG1579_lambda_invalid = []() -> GenericMoveOnly<char> {
} // end namespace cwg1579

namespace cwg1584 { // cwg1584: 7 drafting 2015-05
#if __cplusplus >= 201103L
// Deducing function types from cv-qualified types
template<typename T> void f(const T *); // #cwg1584-f
template<typename T> void g(T *, const T * = 0);
template<typename T> 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<void ()>' requested here}}
template<typename T> 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<typename T> void f(const T *); // #cwg1584-f
template<typename T> void g(T *, const T * = 0);
template<typename T> 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<void ()>' requested here}}
template<typename T> 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<typename T> struct tuple_size {
static const bool is_primary = true;
};
template<typename T> struct tuple_size<T const> : tuple_size<T> {
static const bool is_primary = false;
};

tuple_size<void()> t;
static_assert(tuple_size<void()>::is_primary, "");
static_assert(tuple_size<void()const>::is_primary, "");
} // namespace cwg1584

namespace cwg1589 { // cwg1589: 3.7 c++11
#if __cplusplus >= 201103L
// Ambiguous ranking of list-initialization sequences
Expand Down
27 changes: 26 additions & 1 deletion clang/test/CXX/drs/cwg7xx.cpp
Original file line number Diff line number Diff line change
@@ -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 {};
Expand Down Expand Up @@ -71,6 +76,26 @@ namespace cwg712 { // cwg712: partial
#endif
}

namespace cwg713 { // cwg713: 3.0
template<typename T>
struct is_const {
static const bool value = __is_const(T);
};
template<typename T>
struct is_volatile {
static const bool value = __is_volatile(T);
};

static_assert(!is_const<void()const>::value, "");
static_assert(!is_const<void()const volatile>::value, "");
static_assert(!is_volatile<void()volatile>::value, "");
static_assert(!is_volatile<void()const volatile>::value, "");
#if __cplusplus >= 201103L
static_assert(!is_const<void()const&>::value, "");
static_assert(!is_volatile<void()volatile&>::value, "");
#endif
} // namespace cwg713

namespace cwg727 { // cwg727: partial
struct A {
template<typename T> struct C; // #cwg727-C
Expand Down
2 changes: 1 addition & 1 deletion clang/www/cxx_dr_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -4327,7 +4327,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/713.html">713</a></td>
<td>CD2</td>
<td>Unclear note about cv-qualified function types</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 3.0</td>
</tr>
<tr id="714">
<td><a href="https://cplusplus.github.io/CWG/issues/714.html">714</a></td>
Expand Down

0 comments on commit 30e5d71

Please sign in to comment.