Skip to content

Commit

Permalink
Remove C++03 compatability from unit tests
Browse files Browse the repository at this point in the history
As part of #127, code for unsupported compilation modes/platforms will
be removed. In alignment with this goal, the present patch remove all
checks against C++03 and the corresponding code from the unit test
located under `.upstream-test/`.

This patch relates to #127.
  • Loading branch information
Martin Marenz committed Aug 31, 2023
1 parent c17cac0 commit 12ac6c8
Show file tree
Hide file tree
Showing 95 changed files with 47 additions and 530 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ __host__ __device__
void test() {
static_assert(_LIBCUDACXX_ALIGNOF(T) == cuda::std::alignment_of<T>::value, "");
static_assert(_LIBCUDACXX_ALIGNOF(T) == TEST_ALIGNOF(T), "");
#if TEST_STD_VER >= 11
static_assert(_LIBCUDACXX_ALIGNOF(T) == alignof(T), "");
#endif
#ifdef TEST_COMPILER_CLANG
static_assert(_LIBCUDACXX_ALIGNOF(T) == _Alignof(T), "");
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ static_assert(( cuda::std::__libcpp_is_referenceable<Foo>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<const Foo>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<Foo &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<const Foo &>::value), "");
#if TEST_STD_VER >= 11
static_assert(( cuda::std::__libcpp_is_referenceable<Foo &&>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<const Foo &&>::value), "");
#endif

#ifndef _LIBCUDACXX_HAS_NO_VECTOR_EXTENSION
static_assert(( cuda::std::__libcpp_is_referenceable<int __attribute__((__vector_size__( 8)))>::value), "");
Expand All @@ -47,149 +45,117 @@ static_assert(( cuda::std::__libcpp_is_referenceable<const float __attribute__((

// Functions without cv-qualifiers are referenceable
static_assert(( cuda::std::__libcpp_is_referenceable<void ()>::value), "");
#if TEST_STD_VER >= 11
static_assert((!cuda::std::__libcpp_is_referenceable<void () const>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void () &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void () const &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void () &&>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void () const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (int)>::value), "");
#if TEST_STD_VER >= 11
static_assert((!cuda::std::__libcpp_is_referenceable<void (int) const>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int) &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int) const &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int) &&>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int) const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (int, float)>::value), "");
#if TEST_STD_VER >= 11
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float) const>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float) &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float) const &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float) &&>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float) const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (int, float, Foo &)>::value), "");
#if TEST_STD_VER >= 11
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, Foo &) const>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, Foo &) &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, Foo &) const &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, Foo &) &&>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, Foo &) const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (...)>::value), "");
#if TEST_STD_VER >= 11
static_assert((!cuda::std::__libcpp_is_referenceable<void (...) const>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (...) &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (...) const &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (...) &&>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (...) const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (int, ...)>::value), "");
#if TEST_STD_VER >= 11
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, ...) const>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, ...) &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, ...) const &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, ...) &&>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, ...) const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (int, float, ...)>::value), "");
#if TEST_STD_VER >= 11
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, ...) const>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, ...) &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, ...) const &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, ...) &&>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, ...) const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (int, float, Foo &, ...)>::value), "");
#if TEST_STD_VER >= 11
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, Foo &, ...) const>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, Foo &, ...) &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, Foo &, ...) const &>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, Foo &, ...) &&>::value), "");
static_assert((!cuda::std::__libcpp_is_referenceable<void (int, float, Foo &, ...) const &&>::value), "");
#endif

// member functions with or without cv-qualifiers are referenceable
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)()>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)() const>::value), "");
#if TEST_STD_VER >= 11
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)() &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)() const &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)() &&>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)() const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int)>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int) const>::value), "");
#if TEST_STD_VER >= 11
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int) &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int) const &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int) &&>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int) const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float)>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float) const>::value), "");
#if TEST_STD_VER >= 11
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float) &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float) const &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float) &&>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float) const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, Foo &)>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, Foo &) const>::value), "");
#if TEST_STD_VER >= 11
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, Foo &) &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, Foo &) const &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, Foo &) &&>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, Foo &) const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(...)>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(...) const>::value), "");
#if TEST_STD_VER >= 11
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(...) &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(...) const &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(...) &&>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(...) const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, ...)>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, ...) const>::value), "");
#if TEST_STD_VER >= 11
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, ...) &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, ...) const &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, ...) &&>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, ...) const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, ...)>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, ...) const>::value), "");
#if TEST_STD_VER >= 11
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, ...) &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, ...) const &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, ...) &&>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, ...) const &&>::value), "");
#endif

static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, Foo &, ...)>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, Foo &, ...) const>::value), "");
#if TEST_STD_VER >= 11
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, Foo &, ...) &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, Foo &, ...) const &>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, Foo &, ...) &&>::value), "");
static_assert(( cuda::std::__libcpp_is_referenceable<void (Foo::*)(int, float, Foo &, ...) const &&>::value), "");
#endif

int main(int, char**) {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@
// Disable the missing braces warning for this reason.
#include "disable_missing_braces_warning.h"

// In C++03 the copy assignment operator is not deleted when the implicitly
// generated operator would be ill-formed; like in the case of a struct with a
// const member.
#if TEST_STD_VER < 11
#define TEST_NOT_COPY_ASSIGNABLE(T) ((void)0)
#else
#define TEST_NOT_COPY_ASSIGNABLE(T) static_assert(!cuda::std::is_copy_assignable<T>::value, "")
#endif

struct NoDefault {
__host__ __device__ NoDefault(int) {}
};
Expand All @@ -50,7 +41,7 @@ int main(int, char**) {
C c2 = c;
unused(c2);
static_assert(cuda::std::is_copy_constructible<C>::value, "");
TEST_NOT_COPY_ASSIGNABLE(C);
static_assert(!cuda::std::is_copy_assignable<C>::value, "");
}
{
typedef double T;
Expand All @@ -70,7 +61,7 @@ int main(int, char**) {
C c2 = c;
unused(c2);
static_assert(cuda::std::is_copy_constructible<C>::value, "");
TEST_NOT_COPY_ASSIGNABLE(C);
static_assert(!cuda::std::is_copy_assignable<C>::value, "");
}
{
typedef NoDefault T;
Expand All @@ -89,7 +80,7 @@ int main(int, char**) {
C c2 = c;
unused(c2);
static_assert(cuda::std::is_copy_constructible<C>::value, "");
TEST_NOT_COPY_ASSIGNABLE(C);
static_assert(!cuda::std::is_copy_assignable<C>::value, "");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ int main(int, char**)
assert(c.max_size() == 0);
assert(c.empty());
}
#if TEST_STD_VER >= 11
{
typedef double T;
typedef cuda::std::array<T, 3> C;
Expand All @@ -54,7 +53,6 @@ int main(int, char**)
static_assert(c.max_size() == 0, "");
static_assert(c.empty(), "");
}
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,15 @@ int main(int, char**)
C0 l = {};
C0 r = {};
swap(l, r);
#if TEST_STD_VER >= 11
static_assert(noexcept(swap(l, r)), "");
#endif
}
#if TEST_STD_VER >= 11
{
// NonSwappable is still considered swappable in C++03 because there
// is no access control SFINAE.
typedef NonSwappable T;
typedef cuda::std::array<T, 42> C1;
static_assert(!can_swap<C1&>::value, "");
}
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ int main(int, char**)
C0 l = {};
C0 r = {};
l.swap(r);
#if TEST_STD_VER >= 11
static_assert(noexcept(l.swap(r)), "");
#endif
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@

#include "test_macros.h"

#if TEST_STD_VER < 11
#error
#else

// <cuda/std/iterator>
// template <class C> auto begin(C& c) -> decltype(c.begin());
// template <class C> auto begin(const C& c) -> decltype(c.begin());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ int main(int, char**)
test(s+5, 4, '0');
}
#if defined(_LIBCUDACXX_HAS_MEMORY)
#if TEST_STD_VER >= 11
{
int i[5];
typedef cuda::std::unique_ptr<int, do_nothing> Ptr;
Expand All @@ -64,7 +63,6 @@ int main(int, char**)
test(p, 3, Ptr(i+3));
}
#endif
#endif
#if TEST_STD_VER > 14
{
constexpr const char *p = "123456789";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ int main(int, char**)
test(&a, A());
}
#if defined(_LIBCUDACXX_HAS_MEMORY)
#if TEST_STD_VER >= 11
{
int i;
cuda::std::unique_ptr<int, do_nothing> p(&i);
test(&p, cuda::std::unique_ptr<int, do_nothing>(&i));
}
#endif
#endif
#if TEST_STD_VER > 14
{
constexpr const char *p = "123456789";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ test()
static_assert((cuda::std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
static_assert((cuda::std::is_same<typename R::pointer, It>::value), "");
static_assert((cuda::std::is_same<typename R::value_type, typename T::value_type>::value), "");
#if TEST_STD_VER >= 11
static_assert((cuda::std::is_same<typename R::reference, typename R::value_type&&>::value), "");
#else
static_assert((cuda::std::is_same<typename R::reference, typename T::reference>::value), "");
#endif
static_assert((cuda::std::is_same<typename R::iterator_category, typename T::iterator_category>::value), "");
}

Expand All @@ -64,7 +60,6 @@ int main(int, char**)
test<bidirectional_iterator<char*> >();
test<random_access_iterator<char*> >();
test<char*>();
#if TEST_STD_VER >= 11
{
typedef DummyIt<int, int> T;
typedef cuda::std::move_iterator<T> It;
Expand Down Expand Up @@ -92,7 +87,6 @@ int main(int, char**)
typedef cuda::std::move_iterator<T> It;
static_assert(cuda::std::is_same<It::reference, int&&>::value, "");
}
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ __host__ __device__ TEST_CONSTEXPR_CXX17 bool tests() {
// Test non-subtractable base iterator types
static_assert( HasMinus<cuda::std::reverse_iterator<int*>, cuda::std::reverse_iterator<int*> >::value, "");
static_assert( HasMinus<cuda::std::reverse_iterator<int*>, cuda::std::reverse_iterator<const int*> >::value, "");
#if TEST_STD_VER >= 11
static_assert(!HasMinus<cuda::std::reverse_iterator<int*>, cuda::std::reverse_iterator<char*> >::value, "");
static_assert(!HasMinus<cuda::std::reverse_iterator<bidirectional_iterator<int*> >, cuda::std::reverse_iterator<bidirectional_iterator<int*> > >::value, "");
#endif

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@ struct S { S(); }; // not constexpr

int main(int, char**)
{
#if TEST_STD_VER >= 11
{
{
constexpr cuda::std::istream_iterator<S> it;
}
#else
#error "C++11 only test"
#endif
}

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ int main(int, char**)
typedef cuda::std::istream_iterator<int> T;
T it;
assert(it == T());
#if TEST_STD_VER >= 11
constexpr T it2;
(void)it2;
#endif
}

#if TEST_STD_VER > 14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,15 @@ int main(int, char**)
typedef cuda::std::istreambuf_iterator<char> T;
T it;
assert(it == T());
#if TEST_STD_VER >= 11
constexpr T it2;
(void)it2;
#endif
}
{
typedef cuda::std::istreambuf_iterator<wchar_t> T;
T it;
assert(it == T());
#if TEST_STD_VER >= 11
constexpr T it2;
(void)it2;
#endif
}

return 0;
Expand Down
Loading

0 comments on commit 12ac6c8

Please sign in to comment.