Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove remaining C++03 compatibility from unit tests #1228

Merged
merged 5 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ int main(int, char**)
#endif // !defined(_LIBCUDACXX_HAS_NO_INT128)
}

#if TEST_STD_VER >= 2011
{
static_assert(test<char>(), "");
static_assert(test<int>(), "");
Expand All @@ -51,7 +50,6 @@ int main(int, char**)
static_assert(test<__int128_t>(), "");
#endif // !defined(_LIBCUDACXX_HAS_NO_INT128)
}
#endif // TEST_STD_VER >= 2011

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,15 @@

#include "test_macros.h"

#if TEST_STD_VER >= 2011
// Ensure that static initialization happens; this is PR#37226
extern std::atomic_flag global;
struct X { X() { global.test_and_set(); }};
X x;
std::atomic_flag global = ATOMIC_FLAG_INIT;
#endif

int main(int, char**)
{
#if TEST_STD_VER >= 2011
assert(global.test_and_set() == 1);
#endif
{
std::atomic_flag f(false);
assert(f.test_and_set() == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ void do_exit() {

int main(int, char**)
{
#if TEST_STD_VER >= 2011
{
typedef int T;
typedef std::vector<T, min_allocator<T>> C;
Expand All @@ -40,7 +39,6 @@ int main(int, char**)
volatile T foo = c[c.size()]; // bad, but not caught by ASAN
((void)foo);
}
#endif

{
typedef cpp17_input_iterator<int*> MyInputIter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ void test_push_back() {
}

void test_emplace_back() {
#if TEST_STD_VER >= 2011
std::vector<X> v;
v.reserve(2);
v.push_back(X(2));
Expand All @@ -84,7 +83,6 @@ void test_emplace_back() {
}
assert(v.size() == 1);
assert(is_contiguous_container_asan_correct(v));
#endif
}

void test_insert_range() {
Expand Down Expand Up @@ -122,7 +120,6 @@ void test_insert() {
}

void test_emplace() {
#if TEST_STD_VER >= 2011
std::vector<X> v;
v.reserve(3);
v.insert(v.end(), X(1));
Expand All @@ -136,7 +133,6 @@ void test_emplace() {
}
assert(v.size() == 2);
assert(is_contiguous_container_asan_correct(v));
#endif
}

void test_insert_range2() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ int main(int, char**)
++i;
assert(false);
}
#if TEST_STD_VER >= 2011
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
Expand All @@ -48,7 +47,6 @@ int main(int, char**)
++i;
assert(false);
}
#endif
}

#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ int main(int, char**)
C::value_type j = *i;
assert(false);
}
#if TEST_STD_VER >= 2011
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
Expand All @@ -44,7 +43,6 @@ int main(int, char**)
C::value_type j = *i;
assert(false);
}
#endif
}

#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ int main(int, char**)
++i;
assert(false);
}
#if TEST_STD_VER >= 2011
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
Expand All @@ -44,7 +43,6 @@ int main(int, char**)
++i;
assert(false);
}
#endif

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ int main(int, char**)
C::value_type j = *i;
assert(false);
}
#if TEST_STD_VER >= 2011
{
typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
min_allocator<std::pair<const int, std::string>>> C;
Expand All @@ -42,7 +41,6 @@ int main(int, char**)
C::value_type j = *i;
assert(false);
}
#endif
}

#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,26 +99,20 @@ int main(int, char**) {
std::max_element(std::begin(arr), std::end(arr), std::greater<int>());
std::max(1, 2);
std::max(1, 2, std::greater<int>());
#if TEST_STD_VER >= 2011
std::max({1, 2, 3});
std::max({1, 2, 3}, std::greater<int>());
#endif
std::min_element(std::begin(arr), std::end(arr));
std::min_element(std::begin(arr), std::end(arr), std::greater<int>());
std::min(1, 2);
std::min(1, 2, std::greater<int>());
#if TEST_STD_VER >= 2011
std::min({1, 2, 3});
std::min({1, 2, 3}, std::greater<int>());
#endif
std::minmax_element(std::begin(arr), std::end(arr));
std::minmax_element(std::begin(arr), std::end(arr), std::greater<int>());
std::minmax(1, 2);
std::minmax(1, 2, std::greater<int>());
#if TEST_STD_VER >= 2011
std::minmax({1, 2, 3});
std::minmax({1, 2, 3}, std::greater<int>());
#endif
std::mismatch(std::begin(arr), std::end(arr), std::begin(arr));
std::mismatch(std::begin(arr), std::end(arr), std::begin(arr),
std::greater<int>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
#include "test_macros.h"
#include "test_iterators.h"

#if TEST_STD_VER >= 2011
#define DELETE_FUNCTION = delete
#else
#define DELETE_FUNCTION
#endif

class T; // incomplete

class my_input_iterator_tag : public std::input_iterator_tag {};
Expand Down Expand Up @@ -70,7 +64,7 @@ class my_input_iterator
{return !(x == y);}

template <class T>
void operator,(T const &) DELETE_FUNCTION;
void operator,(T const &) = delete;
};

template <class T, class U>
Expand Down Expand Up @@ -178,11 +172,9 @@ int main(int, char**)
static_assert(( std::__libcpp_is_trivial_iterator<std::basic_string<char>::reverse_iterator> ::value), "");
static_assert(( std::__libcpp_is_trivial_iterator<std::basic_string<char>::const_reverse_iterator>::value), "");

#if TEST_STD_VER >= 2011
// Initializer list (which has no reverse iterators)
static_assert(( std::__libcpp_is_trivial_iterator<std::initializer_list<char>::iterator> ::value), "");
static_assert(( std::__libcpp_is_trivial_iterator<std::initializer_list<char>::const_iterator> ::value), "");
#endif


return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,11 @@ void test_allocator_and_new_match() {
stats.reset();
#elif defined(NO_SIZE)
stats.reset();
#if TEST_STD_VER >= 2011
{
int* x = new int(42);
delete x;
assert(stats.expect_plain());
}
#endif
stats.reset();
{
AlignedType* a = new AlignedType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ int main(int, char**) {
}
{
static_assert((!std::is_constructible<std::align_val_t, std::size_t>::value), "");
#if TEST_STD_VER >= 2011
static_assert(!std::is_constructible<std::size_t, std::align_val_t>::value, "");
#else
static_assert((std::is_constructible<std::size_t, std::align_val_t>::value), "");
#endif
}
{
std::align_val_t a = std::align_val_t(0);
Expand Down
2 changes: 0 additions & 2 deletions libcudacxx/libcxx/test/libcxx/libcpp_alignof.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ template <class T>
void test() {
static_assert(_LIBCUDACXX_ALIGNOF(T) == std::alignment_of<T>::value, "");
static_assert(_LIBCUDACXX_ALIGNOF(T) == TEST_ALIGNOF(T), "");
#if TEST_STD_VER >= 2011
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 @@ -30,15 +30,13 @@ int main(int, char**)
l1.erase(i);
assert(false);
}
#if TEST_STD_VER >= 2011
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S l1("123");
S::const_iterator i = l1.end();
l1.erase(i);
assert(false);
}
#endif
}

#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ int main(int, char**)
l1.erase(i);
assert(false);
}
#if TEST_STD_VER >= 2011
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S l1("123");
Expand All @@ -40,7 +39,6 @@ int main(int, char**)
l1.erase(i);
assert(false);
}
#endif
}

#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ int main(int, char**)
std::string::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
assert(false);
}
#if TEST_STD_VER >= 2011
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S l1("123");
S l2("123");
S::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
assert(false);
}
#endif
}

#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ int main(int, char**)
std::string::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
assert(false);
}
#if TEST_STD_VER >= 2011
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S l1("123");
S l2("123");
S::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
assert(false);
}
#endif
}

#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ int main(int, char**)
std::string::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
assert(false);
}
#if TEST_STD_VER >= 2011
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S l1("123");
S l2("123");
S::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
assert(false);
}
#endif
}

#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ int main(int, char**)
std::string::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
assert(false);
}
#if TEST_STD_VER >= 2011
{
typedef std::basic_string<char, std::char_traits<char>, min_allocator<char>> S;
S l1("123");
S::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
assert(false);
}
#endif
}

#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ int main(int, char**)
static_assert(std::__libcpp_string_gets_noexcept_iterator<random_access_iterator<char *> >::value == expected, "");
static_assert(std::__libcpp_string_gets_noexcept_iterator<ThrowingIterator <char *> >::value == expected, "");

#if TEST_STD_VER >= 2011
static_assert(( std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator <char *> >::value), "");
#else
static_assert(std::__libcpp_string_gets_noexcept_iterator<NonThrowingIterator <char *> >::value == expected, "");
#endif

//
// iterators from libc++'s containers
Expand All @@ -79,11 +75,9 @@ int main(int, char**)
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::basic_string<char>::reverse_iterator> ::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::basic_string<char>::const_reverse_iterator>::value), "");

#if TEST_STD_VER >= 2011
// Initializer list (which has no reverse iterators)
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::initializer_list<char>::iterator> ::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::initializer_list<char>::const_iterator> ::value), "");
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@ int main(int, char**)
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::basic_string<char>::reverse_iterator> ::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::basic_string<char>::const_reverse_iterator>::value), "");

#if TEST_STD_VER >= 2011
// Initializer list (which has no reverse iterators)
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::initializer_list<char>::iterator> ::value), "");
static_assert(( std::__libcpp_string_gets_noexcept_iterator<std::initializer_list<char>::const_iterator> ::value), "");
#endif

return 0;
}
Loading
Loading